repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
tulir/mautrix-python
mautrix_appservice/intent_api.py
HTTPAPI.bot_intent
def bot_intent(self) -> "IntentAPI": """ Get the intent API for the appservice bot. Returns: The IntentAPI for the appservice bot. """ if not self._bot_intent: self._bot_intent = IntentAPI(self.bot_mxid, self, state_store=self.state_store, ...
python
def bot_intent(self) -> "IntentAPI": """ Get the intent API for the appservice bot. Returns: The IntentAPI for the appservice bot. """ if not self._bot_intent: self._bot_intent = IntentAPI(self.bot_mxid, self, state_store=self.state_store, ...
[ "def", "bot_intent", "(", "self", ")", "->", "\"IntentAPI\"", ":", "if", "not", "self", ".", "_bot_intent", ":", "self", ".", "_bot_intent", "=", "IntentAPI", "(", "self", ".", "bot_mxid", ",", "self", ",", "state_store", "=", "self", ".", "state_store", ...
Get the intent API for the appservice bot. Returns: The IntentAPI for the appservice bot.
[ "Get", "the", "intent", "API", "for", "the", "appservice", "bot", "." ]
21bb0870e4103dd03ecc61396ce02adb9301f382
https://github.com/tulir/mautrix-python/blob/21bb0870e4103dd03ecc61396ce02adb9301f382/mautrix_appservice/intent_api.py#L92-L102
train
tulir/mautrix-python
mautrix_appservice/intent_api.py
HTTPAPI.intent
def intent(self, user: str = None, token: Optional[str] = None) -> "IntentAPI": """ Get the intent API for a specific user. Args: user: The Matrix ID of the user whose intent API to get. Returns: The IntentAPI for the given user. """ if self.is_r...
python
def intent(self, user: str = None, token: Optional[str] = None) -> "IntentAPI": """ Get the intent API for a specific user. Args: user: The Matrix ID of the user whose intent API to get. Returns: The IntentAPI for the given user. """ if self.is_r...
[ "def", "intent", "(", "self", ",", "user", ":", "str", "=", "None", ",", "token", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "\"IntentAPI\"", ":", "if", "self", ".", "is_real_user", ":", "raise", "ValueError", "(", "\"Can't get child inten...
Get the intent API for a specific user. Args: user: The Matrix ID of the user whose intent API to get. Returns: The IntentAPI for the given user.
[ "Get", "the", "intent", "API", "for", "a", "specific", "user", "." ]
21bb0870e4103dd03ecc61396ce02adb9301f382
https://github.com/tulir/mautrix-python/blob/21bb0870e4103dd03ecc61396ce02adb9301f382/mautrix_appservice/intent_api.py#L104-L120
train
tulir/mautrix-python
mautrix_appservice/intent_api.py
HTTPAPI.request
def request(self, method: str, path: str, content: Optional[Union[dict, bytes, str]] = None, timestamp: Optional[int] = None, external_url: Optional[str] = None, headers: Optional[Dict[str, str]] = None, query_params: Optional[Dict[str, Any]] = None, api_p...
python
def request(self, method: str, path: str, content: Optional[Union[dict, bytes, str]] = None, timestamp: Optional[int] = None, external_url: Optional[str] = None, headers: Optional[Dict[str, str]] = None, query_params: Optional[Dict[str, Any]] = None, api_p...
[ "def", "request", "(", "self", ",", "method", ":", "str", ",", "path", ":", "str", ",", "content", ":", "Optional", "[", "Union", "[", "dict", ",", "bytes", ",", "str", "]", "]", "=", "None", ",", "timestamp", ":", "Optional", "[", "int", "]", "=...
Make a raw HTTP request. Args: method: The HTTP method to use. path: The API endpoint to call. Does not include the base path (e.g. /_matrix/client/r0). content: The content to post as a dict (json) or bytes/str (raw). timestamp: The timestamp query param used fo...
[ "Make", "a", "raw", "HTTP", "request", "." ]
21bb0870e4103dd03ecc61396ce02adb9301f382
https://github.com/tulir/mautrix-python/blob/21bb0870e4103dd03ecc61396ce02adb9301f382/mautrix_appservice/intent_api.py#L149-L198
train
secnot/rectpack
rectpack/guillotine.py
Guillotine._add_section
def _add_section(self, section): """Adds a new section to the free section list, but before that and if section merge is enabled, tries to join the rectangle with all existing sections, if successful the resulting section is again merged with the remaining sections until the operation...
python
def _add_section(self, section): """Adds a new section to the free section list, but before that and if section merge is enabled, tries to join the rectangle with all existing sections, if successful the resulting section is again merged with the remaining sections until the operation...
[ "def", "_add_section", "(", "self", ",", "section", ")", ":", "section", ".", "rid", "=", "0", "plen", "=", "0", "while", "self", ".", "_merge", "and", "self", ".", "_sections", "and", "plen", "!=", "len", "(", "self", ".", "_sections", ")", ":", "...
Adds a new section to the free section list, but before that and if section merge is enabled, tries to join the rectangle with all existing sections, if successful the resulting section is again merged with the remaining sections until the operation fails. The result is then appended...
[ "Adds", "a", "new", "section", "to", "the", "free", "section", "list", "but", "before", "that", "and", "if", "section", "merge", "is", "enabled", "tries", "to", "join", "the", "rectangle", "with", "all", "existing", "sections", "if", "successful", "the", "...
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/guillotine.py#L24-L40
train
secnot/rectpack
rectpack/enclose.py
Enclose._refine_candidate
def _refine_candidate(self, width, height): """ Use bottom-left packing algorithm to find a lower height for the container. Arguments: width height Returns: tuple (width, height, PackingAlgorithm): """ packer = newPacker(Pack...
python
def _refine_candidate(self, width, height): """ Use bottom-left packing algorithm to find a lower height for the container. Arguments: width height Returns: tuple (width, height, PackingAlgorithm): """ packer = newPacker(Pack...
[ "def", "_refine_candidate", "(", "self", ",", "width", ",", "height", ")", ":", "packer", "=", "newPacker", "(", "PackingMode", ".", "Offline", ",", "PackingBin", ".", "BFF", ",", "pack_algo", "=", "self", ".", "_pack_algo", ",", "sort_algo", "=", "SORT_LS...
Use bottom-left packing algorithm to find a lower height for the container. Arguments: width height Returns: tuple (width, height, PackingAlgorithm):
[ "Use", "bottom", "-", "left", "packing", "algorithm", "to", "find", "a", "lower", "height", "for", "the", "container", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/enclose.py#L89-L117
train
secnot/rectpack
rectpack/maxrects.py
MaxRects._generate_splits
def _generate_splits(self, m, r): """ When a rectangle is placed inside a maximal rectangle, it stops being one and up to 4 new maximal rectangles may appear depending on the placement. _generate_splits calculates them. Arguments: m (Rectangle): max_rect rectangle ...
python
def _generate_splits(self, m, r): """ When a rectangle is placed inside a maximal rectangle, it stops being one and up to 4 new maximal rectangles may appear depending on the placement. _generate_splits calculates them. Arguments: m (Rectangle): max_rect rectangle ...
[ "def", "_generate_splits", "(", "self", ",", "m", ",", "r", ")", ":", "new_rects", "=", "[", "]", "if", "r", ".", "left", ">", "m", ".", "left", ":", "new_rects", ".", "append", "(", "Rectangle", "(", "m", ".", "left", ",", "m", ".", "bottom", ...
When a rectangle is placed inside a maximal rectangle, it stops being one and up to 4 new maximal rectangles may appear depending on the placement. _generate_splits calculates them. Arguments: m (Rectangle): max_rect rectangle r (Rectangle): rectangle placed Ret...
[ "When", "a", "rectangle", "is", "placed", "inside", "a", "maximal", "rectangle", "it", "stops", "being", "one", "and", "up", "to", "4", "new", "maximal", "rectangles", "may", "appear", "depending", "on", "the", "placement", ".", "_generate_splits", "calculates...
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/maxrects.py#L70-L94
train
secnot/rectpack
rectpack/maxrects.py
MaxRects._remove_duplicates
def _remove_duplicates(self): """ Remove every maximal rectangle contained by another one. """ contained = set() for m1, m2 in itertools.combinations(self._max_rects, 2): if m1.contains(m2): contained.add(m2) elif m2.contains(m1): ...
python
def _remove_duplicates(self): """ Remove every maximal rectangle contained by another one. """ contained = set() for m1, m2 in itertools.combinations(self._max_rects, 2): if m1.contains(m2): contained.add(m2) elif m2.contains(m1): ...
[ "def", "_remove_duplicates", "(", "self", ")", ":", "contained", "=", "set", "(", ")", "for", "m1", ",", "m2", "in", "itertools", ".", "combinations", "(", "self", ".", "_max_rects", ",", "2", ")", ":", "if", "m1", ".", "contains", "(", "m2", ")", ...
Remove every maximal rectangle contained by another one.
[ "Remove", "every", "maximal", "rectangle", "contained", "by", "another", "one", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/maxrects.py#L118-L130
train
secnot/rectpack
rectpack/maxrects.py
MaxRects.fitness
def fitness(self, width, height): """ Metric used to rate how much space is wasted if a rectangle is placed. Returns a value greater or equal to zero, the smaller the value the more 'fit' is the rectangle. If the rectangle can't be placed, returns None. Arguments: ...
python
def fitness(self, width, height): """ Metric used to rate how much space is wasted if a rectangle is placed. Returns a value greater or equal to zero, the smaller the value the more 'fit' is the rectangle. If the rectangle can't be placed, returns None. Arguments: ...
[ "def", "fitness", "(", "self", ",", "width", ",", "height", ")", ":", "assert", "(", "width", ">", "0", "and", "height", ">", "0", ")", "rect", ",", "max_rect", "=", "self", ".", "_select_position", "(", "width", ",", "height", ")", "if", "rect", "...
Metric used to rate how much space is wasted if a rectangle is placed. Returns a value greater or equal to zero, the smaller the value the more 'fit' is the rectangle. If the rectangle can't be placed, returns None. Arguments: width (int, float): Rectangle width height ...
[ "Metric", "used", "to", "rate", "how", "much", "space", "is", "wasted", "if", "a", "rectangle", "is", "placed", ".", "Returns", "a", "value", "greater", "or", "equal", "to", "zero", "the", "smaller", "the", "value", "the", "more", "fit", "is", "the", "...
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/maxrects.py#L132-L153
train
secnot/rectpack
rectpack/maxrects.py
MaxRectsBl._select_position
def _select_position(self, w, h): """ Select the position where the y coordinate of the top of the rectangle is lower, if there are severtal pick the one with the smallest x coordinate """ fitn = ((m.y+h, m.x, w, h, m) for m in self._max_rects if self._...
python
def _select_position(self, w, h): """ Select the position where the y coordinate of the top of the rectangle is lower, if there are severtal pick the one with the smallest x coordinate """ fitn = ((m.y+h, m.x, w, h, m) for m in self._max_rects if self._...
[ "def", "_select_position", "(", "self", ",", "w", ",", "h", ")", ":", "fitn", "=", "(", "(", "m", ".", "y", "+", "h", ",", "m", ".", "x", ",", "w", ",", "h", ",", "m", ")", "for", "m", "in", "self", ".", "_max_rects", "if", "self", ".", "...
Select the position where the y coordinate of the top of the rectangle is lower, if there are severtal pick the one with the smallest x coordinate
[ "Select", "the", "position", "where", "the", "y", "coordinate", "of", "the", "top", "of", "the", "rectangle", "is", "lower", "if", "there", "are", "severtal", "pick", "the", "one", "with", "the", "smallest", "x", "coordinate" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/maxrects.py#L196-L217
train
secnot/rectpack
rectpack/pack_algo.py
PackingAlgorithm._fits_surface
def _fits_surface(self, width, height): """ Test surface is big enough to place a rectangle Arguments: width (int, float): Rectangle width height (int, float): Rectangle height Returns: boolean: True if it could be placed, False otherwise """...
python
def _fits_surface(self, width, height): """ Test surface is big enough to place a rectangle Arguments: width (int, float): Rectangle width height (int, float): Rectangle height Returns: boolean: True if it could be placed, False otherwise """...
[ "def", "_fits_surface", "(", "self", ",", "width", ",", "height", ")", ":", "assert", "(", "width", ">", "0", "and", "height", ">", "0", ")", "if", "self", ".", "rot", "and", "(", "width", ">", "self", ".", "width", "or", "height", ">", "self", "...
Test surface is big enough to place a rectangle Arguments: width (int, float): Rectangle width height (int, float): Rectangle height Returns: boolean: True if it could be placed, False otherwise
[ "Test", "surface", "is", "big", "enough", "to", "place", "a", "rectangle" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/pack_algo.py#L31-L49
train
secnot/rectpack
rectpack/pack_algo.py
PackingAlgorithm.validate_packing
def validate_packing(self): """ Check for collisions between rectangles, also check all are placed inside surface. """ surface = Rectangle(0, 0, self.width, self.height) for r in self: if not surface.contains(r): raise Exception("Rectangle pla...
python
def validate_packing(self): """ Check for collisions between rectangles, also check all are placed inside surface. """ surface = Rectangle(0, 0, self.width, self.height) for r in self: if not surface.contains(r): raise Exception("Rectangle pla...
[ "def", "validate_packing", "(", "self", ")", ":", "surface", "=", "Rectangle", "(", "0", ",", "0", ",", "self", ".", "width", ",", "self", ".", "height", ")", "for", "r", "in", "self", ":", "if", "not", "surface", ".", "contains", "(", "r", ")", ...
Check for collisions between rectangles, also check all are placed inside surface.
[ "Check", "for", "collisions", "between", "rectangles", "also", "check", "all", "are", "placed", "inside", "surface", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/pack_algo.py#L111-L130
train
secnot/rectpack
rectpack/waste.py
WasteManager.add_waste
def add_waste(self, x, y, width, height): """Add new waste section""" self._add_section(Rectangle(x, y, width, height))
python
def add_waste(self, x, y, width, height): """Add new waste section""" self._add_section(Rectangle(x, y, width, height))
[ "def", "add_waste", "(", "self", ",", "x", ",", "y", ",", "width", ",", "height", ")", ":", "self", ".", "_add_section", "(", "Rectangle", "(", "x", ",", "y", ",", "width", ",", "height", ")", ")" ]
Add new waste section
[ "Add", "new", "waste", "section" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/waste.py#L11-L13
train
secnot/rectpack
rectpack/geometry.py
Point.distance
def distance(self, point): """ Calculate distance to another point """ return sqrt((self.x-point.x)**2+(self.y-point.y)**2)
python
def distance(self, point): """ Calculate distance to another point """ return sqrt((self.x-point.x)**2+(self.y-point.y)**2)
[ "def", "distance", "(", "self", ",", "point", ")", ":", "return", "sqrt", "(", "(", "self", ".", "x", "-", "point", ".", "x", ")", "**", "2", "+", "(", "self", ".", "y", "-", "point", ".", "y", ")", "**", "2", ")" ]
Calculate distance to another point
[ "Calculate", "distance", "to", "another", "point" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/geometry.py#L19-L23
train
secnot/rectpack
rectpack/geometry.py
Rectangle.move
def move(self, x, y): """ Move Rectangle to x,y coordinates Arguments: x (int, float): X coordinate y (int, float): Y coordinate """ self.x = x self.y = y
python
def move(self, x, y): """ Move Rectangle to x,y coordinates Arguments: x (int, float): X coordinate y (int, float): Y coordinate """ self.x = x self.y = y
[ "def", "move", "(", "self", ",", "x", ",", "y", ")", ":", "self", ".", "x", "=", "x", "self", ".", "y", "=", "y" ]
Move Rectangle to x,y coordinates Arguments: x (int, float): X coordinate y (int, float): Y coordinate
[ "Move", "Rectangle", "to", "x", "y", "coordinates" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/geometry.py#L226-L235
train
secnot/rectpack
rectpack/geometry.py
Rectangle.contains
def contains(self, rect): """ Tests if another rectangle is contained by this one Arguments: rect (Rectangle): The other rectangle Returns: bool: True if it is container, False otherwise """ return (rect.y >= self.y and \ rect.x >...
python
def contains(self, rect): """ Tests if another rectangle is contained by this one Arguments: rect (Rectangle): The other rectangle Returns: bool: True if it is container, False otherwise """ return (rect.y >= self.y and \ rect.x >...
[ "def", "contains", "(", "self", ",", "rect", ")", ":", "return", "(", "rect", ".", "y", ">=", "self", ".", "y", "and", "rect", ".", "x", ">=", "self", ".", "x", "and", "rect", ".", "y", "+", "rect", ".", "height", "<=", "self", ".", "y", "+",...
Tests if another rectangle is contained by this one Arguments: rect (Rectangle): The other rectangle Returns: bool: True if it is container, False otherwise
[ "Tests", "if", "another", "rectangle", "is", "contained", "by", "this", "one" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/geometry.py#L237-L250
train
secnot/rectpack
rectpack/geometry.py
Rectangle.intersects
def intersects(self, rect, edges=False): """ Detect intersections between this rectangle and rect. Args: rect (Rectangle): Rectangle to test for intersections. edges (bool): Accept edge touching rectangles as intersects or not Returns: bool: True if ...
python
def intersects(self, rect, edges=False): """ Detect intersections between this rectangle and rect. Args: rect (Rectangle): Rectangle to test for intersections. edges (bool): Accept edge touching rectangles as intersects or not Returns: bool: True if ...
[ "def", "intersects", "(", "self", ",", "rect", ",", "edges", "=", "False", ")", ":", "if", "(", "self", ".", "bottom", ">", "rect", ".", "top", "or", "self", ".", "top", "<", "rect", ".", "bottom", "or", "self", ".", "left", ">", "rect", ".", "...
Detect intersections between this rectangle and rect. Args: rect (Rectangle): Rectangle to test for intersections. edges (bool): Accept edge touching rectangles as intersects or not Returns: bool: True if the rectangles intersect, False otherwise
[ "Detect", "intersections", "between", "this", "rectangle", "and", "rect", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/geometry.py#L252-L285
train
secnot/rectpack
rectpack/geometry.py
Rectangle.join
def join(self, other): """ Try to join a rectangle to this one, if the result is also a rectangle and the operation is successful and this rectangle is modified to the union. Arguments: other (Rectangle): Rectangle to join Returns: bool: True when succe...
python
def join(self, other): """ Try to join a rectangle to this one, if the result is also a rectangle and the operation is successful and this rectangle is modified to the union. Arguments: other (Rectangle): Rectangle to join Returns: bool: True when succe...
[ "def", "join", "(", "self", ",", "other", ")", ":", "if", "self", ".", "contains", "(", "other", ")", ":", "return", "True", "if", "other", ".", "contains", "(", "self", ")", ":", "self", ".", "x", "=", "other", ".", "x", "self", ".", "y", "=",...
Try to join a rectangle to this one, if the result is also a rectangle and the operation is successful and this rectangle is modified to the union. Arguments: other (Rectangle): Rectangle to join Returns: bool: True when successfully joined, False otherwise
[ "Try", "to", "join", "a", "rectangle", "to", "this", "one", "if", "the", "result", "is", "also", "a", "rectangle", "and", "the", "operation", "is", "successful", "and", "this", "rectangle", "is", "modified", "to", "the", "union", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/geometry.py#L313-L353
train
secnot/rectpack
rectpack/packer.py
newPacker
def newPacker(mode=PackingMode.Offline, bin_algo=PackingBin.BBF, pack_algo=MaxRectsBssf, sort_algo=SORT_AREA, rotation=True): """ Packer factory helper function Arguments: mode (PackingMode): Packing mode Online: Rectangles are packed as soon are they...
python
def newPacker(mode=PackingMode.Offline, bin_algo=PackingBin.BBF, pack_algo=MaxRectsBssf, sort_algo=SORT_AREA, rotation=True): """ Packer factory helper function Arguments: mode (PackingMode): Packing mode Online: Rectangles are packed as soon are they...
[ "def", "newPacker", "(", "mode", "=", "PackingMode", ".", "Offline", ",", "bin_algo", "=", "PackingBin", ".", "BBF", ",", "pack_algo", "=", "MaxRectsBssf", ",", "sort_algo", "=", "SORT_AREA", ",", "rotation", "=", "True", ")", ":", "packer_class", "=", "No...
Packer factory helper function Arguments: mode (PackingMode): Packing mode Online: Rectangles are packed as soon are they are added Offline: Rectangles aren't packed untils pack() is called bin_algo (PackingBin): Bin selection heuristic pack_algo (PackingAlgorithm): ...
[ "Packer", "factory", "helper", "function" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/packer.py#L524-L578
train
secnot/rectpack
rectpack/packer.py
PackerOnline._new_open_bin
def _new_open_bin(self, width=None, height=None, rid=None): """ Extract the next empty bin and append it to open bins Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin big enough for the rectangle was found """ factories_to_delete = s...
python
def _new_open_bin(self, width=None, height=None, rid=None): """ Extract the next empty bin and append it to open bins Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin big enough for the rectangle was found """ factories_to_delete = s...
[ "def", "_new_open_bin", "(", "self", ",", "width", "=", "None", ",", "height", "=", "None", ",", "rid", "=", "None", ")", ":", "factories_to_delete", "=", "set", "(", ")", "new_bin", "=", "None", "for", "key", ",", "binfac", "in", "self", ".", "_empt...
Extract the next empty bin and append it to open bins Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin big enough for the rectangle was found
[ "Extract", "the", "next", "empty", "bin", "and", "append", "it", "to", "open", "bins" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/packer.py#L227-L261
train
secnot/rectpack
rectpack/packer.py
PackerGlobal._find_best_fit
def _find_best_fit(self, pbin): """ Return best fitness rectangle from rectangles packing _sorted_rect list Arguments: pbin (PackingAlgorithm): Packing bin Returns: key of the rectangle with best fitness """ fit = ((pbin.fitness(r[0], r[1]), k) f...
python
def _find_best_fit(self, pbin): """ Return best fitness rectangle from rectangles packing _sorted_rect list Arguments: pbin (PackingAlgorithm): Packing bin Returns: key of the rectangle with best fitness """ fit = ((pbin.fitness(r[0], r[1]), k) f...
[ "def", "_find_best_fit", "(", "self", ",", "pbin", ")", ":", "fit", "=", "(", "(", "pbin", ".", "fitness", "(", "r", "[", "0", "]", ",", "r", "[", "1", "]", ")", ",", "k", ")", "for", "k", ",", "r", "in", "self", ".", "_sorted_rect", ".", "...
Return best fitness rectangle from rectangles packing _sorted_rect list Arguments: pbin (PackingAlgorithm): Packing bin Returns: key of the rectangle with best fitness
[ "Return", "best", "fitness", "rectangle", "from", "rectangles", "packing", "_sorted_rect", "list" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/packer.py#L404-L420
train
secnot/rectpack
rectpack/packer.py
PackerGlobal._new_open_bin
def _new_open_bin(self, remaining_rect): """ Extract the next bin where at least one of the rectangles in rem Arguments: remaining_rect (dict): rectangles not placed yet Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin b...
python
def _new_open_bin(self, remaining_rect): """ Extract the next bin where at least one of the rectangles in rem Arguments: remaining_rect (dict): rectangles not placed yet Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin b...
[ "def", "_new_open_bin", "(", "self", ",", "remaining_rect", ")", ":", "factories_to_delete", "=", "set", "(", ")", "new_bin", "=", "None", "for", "key", ",", "binfac", "in", "self", ".", "_empty_bins", ".", "items", "(", ")", ":", "a_rectangle_fits", "=", ...
Extract the next bin where at least one of the rectangles in rem Arguments: remaining_rect (dict): rectangles not placed yet Returns: PackingAlgorithm: Initialized empty packing bin. None: No bin big enough for the rectangle was found
[ "Extract", "the", "next", "bin", "where", "at", "least", "one", "of", "the", "rectangles", "in", "rem" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/packer.py#L423-L468
train
secnot/rectpack
rectpack/skyline.py
Skyline._placement_points_generator
def _placement_points_generator(self, skyline, width): """Returns a generator for the x coordinates of all the placement points on the skyline for a given rectangle. WARNING: In some cases could be duplicated points, but it is faster to compute them twice than to remove them. ...
python
def _placement_points_generator(self, skyline, width): """Returns a generator for the x coordinates of all the placement points on the skyline for a given rectangle. WARNING: In some cases could be duplicated points, but it is faster to compute them twice than to remove them. ...
[ "def", "_placement_points_generator", "(", "self", ",", "skyline", ",", "width", ")", ":", "skyline_r", "=", "skyline", "[", "-", "1", "]", ".", "right", "skyline_l", "=", "skyline", "[", "0", "]", ".", "left", "ppointsl", "=", "(", "s", ".", "left", ...
Returns a generator for the x coordinates of all the placement points on the skyline for a given rectangle. WARNING: In some cases could be duplicated points, but it is faster to compute them twice than to remove them. Arguments: skyline (list): Skyline HSegment lis...
[ "Returns", "a", "generator", "for", "the", "x", "coordinates", "of", "all", "the", "placement", "points", "on", "the", "skyline", "for", "a", "given", "rectangle", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L37-L61
train
secnot/rectpack
rectpack/skyline.py
Skyline._generate_placements
def _generate_placements(self, width, height): """ Generate a list with Arguments: skyline (list): SkylineHSegment list width (number): Returns: tuple (Rectangle, fitness): Rectangle: Rectangle in valid position left_...
python
def _generate_placements(self, width, height): """ Generate a list with Arguments: skyline (list): SkylineHSegment list width (number): Returns: tuple (Rectangle, fitness): Rectangle: Rectangle in valid position left_...
[ "def", "_generate_placements", "(", "self", ",", "width", ",", "height", ")", ":", "skyline", "=", "self", ".", "_skyline", "points", "=", "collections", ".", "deque", "(", ")", "left_index", "=", "right_index", "=", "0", "support_height", "=", "skyline", ...
Generate a list with Arguments: skyline (list): SkylineHSegment list width (number): Returns: tuple (Rectangle, fitness): Rectangle: Rectangle in valid position left_skyline: Index for the skyline under the rectangle left edge. ...
[ "Generate", "a", "list", "with" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L63-L115
train
secnot/rectpack
rectpack/skyline.py
Skyline._select_position
def _select_position(self, width, height): """ Search for the placement with the bes fitness for the rectangle. Returns: tuple (Rectangle, fitness) - Rectangle placed in the fittest position None - Rectangle couldn't be placed """ positions = self._genera...
python
def _select_position(self, width, height): """ Search for the placement with the bes fitness for the rectangle. Returns: tuple (Rectangle, fitness) - Rectangle placed in the fittest position None - Rectangle couldn't be placed """ positions = self._genera...
[ "def", "_select_position", "(", "self", ",", "width", ",", "height", ")", ":", "positions", "=", "self", ".", "_generate_placements", "(", "width", ",", "height", ")", "if", "self", ".", "rot", "and", "width", "!=", "height", ":", "positions", "+=", "sel...
Search for the placement with the bes fitness for the rectangle. Returns: tuple (Rectangle, fitness) - Rectangle placed in the fittest position None - Rectangle couldn't be placed
[ "Search", "for", "the", "placement", "with", "the", "bes", "fitness", "for", "the", "rectangle", "." ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L176-L190
train
secnot/rectpack
rectpack/skyline.py
Skyline.fitness
def fitness(self, width, height): """Search for the best fitness """ assert(width > 0 and height >0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None # If there is room in wasted space, FREE PACKING!! ...
python
def fitness(self, width, height): """Search for the best fitness """ assert(width > 0 and height >0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None # If there is room in wasted space, FREE PACKING!! ...
[ "def", "fitness", "(", "self", ",", "width", ",", "height", ")", ":", "assert", "(", "width", ">", "0", "and", "height", ">", "0", ")", "if", "width", ">", "max", "(", "self", ".", "width", ",", "self", ".", "height", ")", "or", "height", ">", ...
Search for the best fitness
[ "Search", "for", "the", "best", "fitness" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L192-L208
train
secnot/rectpack
rectpack/skyline.py
Skyline.add_rect
def add_rect(self, width, height, rid=None): """ Add new rectangle """ assert(width > 0 and height > 0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None rect = None # If Waste managment is enab...
python
def add_rect(self, width, height, rid=None): """ Add new rectangle """ assert(width > 0 and height > 0) if width > max(self.width, self.height) or\ height > max(self.height, self.width): return None rect = None # If Waste managment is enab...
[ "def", "add_rect", "(", "self", ",", "width", ",", "height", ",", "rid", "=", "None", ")", ":", "assert", "(", "width", ">", "0", "and", "height", ">", "0", ")", "if", "width", ">", "max", "(", "self", ".", "width", ",", "self", ".", "height", ...
Add new rectangle
[ "Add", "new", "rectangle" ]
21d46be48fd453500ea49de699bc9eabc427bdf7
https://github.com/secnot/rectpack/blob/21d46be48fd453500ea49de699bc9eabc427bdf7/rectpack/skyline.py#L210-L236
train
spotify/docker_interface
docker_interface/util.py
abspath
def abspath(path, ref=None): """ Create an absolute path. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- path : str absolute path Raises ------ ...
python
def abspath(path, ref=None): """ Create an absolute path. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- path : str absolute path Raises ------ ...
[ "def", "abspath", "(", "path", ",", "ref", "=", "None", ")", ":", "if", "ref", ":", "path", "=", "os", ".", "path", ".", "join", "(", "ref", ",", "path", ")", "if", "not", "os", ".", "path", ".", "isabs", "(", "path", ")", ":", "raise", "Valu...
Create an absolute path. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- path : str absolute path Raises ------ ValueError if an absolute pat...
[ "Create", "an", "absolute", "path", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L29-L54
train
spotify/docker_interface
docker_interface/util.py
split_path
def split_path(path, ref=None): """ Split a path into its components. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- list : str components of the path ...
python
def split_path(path, ref=None): """ Split a path into its components. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- list : str components of the path ...
[ "def", "split_path", "(", "path", ",", "ref", "=", "None", ")", ":", "path", "=", "abspath", "(", "path", ",", "ref", ")", "return", "path", ".", "strip", "(", "os", ".", "path", ".", "sep", ")", ".", "split", "(", "os", ".", "path", ".", "sep"...
Split a path into its components. Parameters ---------- path : str absolute or relative path with respect to `ref` ref : str or None reference path if `path` is relative Returns ------- list : str components of the path
[ "Split", "a", "path", "into", "its", "components", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L57-L74
train
spotify/docker_interface
docker_interface/util.py
get_value
def get_value(instance, path, ref=None): """ Get the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` i...
python
def get_value(instance, path, ref=None): """ Get the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` i...
[ "def", "get_value", "(", "instance", ",", "path", ",", "ref", "=", "None", ")", ":", "for", "part", "in", "split_path", "(", "path", ",", "ref", ")", ":", "if", "isinstance", "(", "instance", ",", "list", ")", ":", "part", "=", "int", "(", "part", ...
Get the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` is relative Returns ------- value : ...
[ "Get", "the", "value", "from", "instance", "at", "the", "given", "path", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L77-L111
train
spotify/docker_interface
docker_interface/util.py
pop_value
def pop_value(instance, path, ref=None): """ Pop the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` i...
python
def pop_value(instance, path, ref=None): """ Pop the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` i...
[ "def", "pop_value", "(", "instance", ",", "path", ",", "ref", "=", "None", ")", ":", "head", ",", "tail", "=", "os", ".", "path", ".", "split", "(", "abspath", "(", "path", ",", "ref", ")", ")", "instance", "=", "get_value", "(", "instance", ",", ...
Pop the value from `instance` at the given `path`. Parameters ---------- instance : dict or list instance from which to retrieve a value path : str path to retrieve a value from ref : str or None reference path if `path` is relative Returns ------- value : ...
[ "Pop", "the", "value", "from", "instance", "at", "the", "given", "path", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L114-L136
train
spotify/docker_interface
docker_interface/util.py
merge
def merge(x, y): """ Merge two dictionaries and raise an error for inconsistencies. Parameters ---------- x : dict dictionary x y : dict dictionary y Returns ------- x : dict merged dictionary Raises ------ ValueError if `x` and `y` are ...
python
def merge(x, y): """ Merge two dictionaries and raise an error for inconsistencies. Parameters ---------- x : dict dictionary x y : dict dictionary y Returns ------- x : dict merged dictionary Raises ------ ValueError if `x` and `y` are ...
[ "def", "merge", "(", "x", ",", "y", ")", ":", "keys_x", "=", "set", "(", "x", ")", "keys_y", "=", "set", "(", "y", ")", "for", "key", "in", "keys_y", "-", "keys_x", ":", "x", "[", "key", "]", "=", "y", "[", "key", "]", "for", "key", "in", ...
Merge two dictionaries and raise an error for inconsistencies. Parameters ---------- x : dict dictionary x y : dict dictionary y Returns ------- x : dict merged dictionary Raises ------ ValueError if `x` and `y` are inconsistent
[ "Merge", "two", "dictionaries", "and", "raise", "an", "error", "for", "inconsistencies", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L181-L218
train
spotify/docker_interface
docker_interface/util.py
set_default_from_schema
def set_default_from_schema(instance, schema): """ Populate default values on an `instance` given a `schema`. Parameters ---------- instance : dict instance to populate default values for schema : dict JSON schema with default values Returns ------- instance : dict ...
python
def set_default_from_schema(instance, schema): """ Populate default values on an `instance` given a `schema`. Parameters ---------- instance : dict instance to populate default values for schema : dict JSON schema with default values Returns ------- instance : dict ...
[ "def", "set_default_from_schema", "(", "instance", ",", "schema", ")", ":", "for", "name", ",", "property_", "in", "schema", ".", "get", "(", "'properties'", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "'default'", "in", "property_", ":", "i...
Populate default values on an `instance` given a `schema`. Parameters ---------- instance : dict instance to populate default values for schema : dict JSON schema with default values Returns ------- instance : dict instance with populated default values
[ "Populate", "default", "values", "on", "an", "instance", "given", "a", "schema", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L221-L244
train
spotify/docker_interface
docker_interface/util.py
apply
def apply(instance, func, path=None): """ Apply `func` to all fundamental types of `instance`. Parameters ---------- instance : dict instance to apply functions to func : callable function with two arguments (instance, path) to apply to all fundamental types recursively path...
python
def apply(instance, func, path=None): """ Apply `func` to all fundamental types of `instance`. Parameters ---------- instance : dict instance to apply functions to func : callable function with two arguments (instance, path) to apply to all fundamental types recursively path...
[ "def", "apply", "(", "instance", ",", "func", ",", "path", "=", "None", ")", ":", "path", "=", "path", "or", "os", ".", "path", ".", "sep", "if", "isinstance", "(", "instance", ",", "list", ")", ":", "return", "[", "apply", "(", "item", ",", "fun...
Apply `func` to all fundamental types of `instance`. Parameters ---------- instance : dict instance to apply functions to func : callable function with two arguments (instance, path) to apply to all fundamental types recursively path : str path in the document (defaults to '...
[ "Apply", "func", "to", "all", "fundamental", "types", "of", "instance", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L247-L270
train
spotify/docker_interface
docker_interface/util.py
get_free_port
def get_free_port(ports=None): """ Get a free port. Parameters ---------- ports : iterable ports to check (obtain a random port by default) Returns ------- port : int a free port """ if ports is None: with contextlib.closing(socket.socket(socket.AF_INET,...
python
def get_free_port(ports=None): """ Get a free port. Parameters ---------- ports : iterable ports to check (obtain a random port by default) Returns ------- port : int a free port """ if ports is None: with contextlib.closing(socket.socket(socket.AF_INET,...
[ "def", "get_free_port", "(", "ports", "=", "None", ")", ":", "if", "ports", "is", "None", ":", "with", "contextlib", ".", "closing", "(", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", ")", "as", "_socke...
Get a free port. Parameters ---------- ports : iterable ports to check (obtain a random port by default) Returns ------- port : int a free port
[ "Get", "a", "free", "port", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/util.py#L273-L303
train
spotify/docker_interface
docker_interface/docker_interface.py
build_parameter_parts
def build_parameter_parts(configuration, *parameters): """ Construct command parts for one or more parameters. Parameters ---------- configuration : dict configuration parameters : list list of parameters to create command line arguments for Yields ------ argument :...
python
def build_parameter_parts(configuration, *parameters): """ Construct command parts for one or more parameters. Parameters ---------- configuration : dict configuration parameters : list list of parameters to create command line arguments for Yields ------ argument :...
[ "def", "build_parameter_parts", "(", "configuration", ",", "*", "parameters", ")", ":", "for", "parameter", "in", "parameters", ":", "values", "=", "configuration", ".", "pop", "(", "parameter", ",", "[", "]", ")", "if", "values", ":", "if", "not", "isinst...
Construct command parts for one or more parameters. Parameters ---------- configuration : dict configuration parameters : list list of parameters to create command line arguments for Yields ------ argument : str command line argument
[ "Construct", "command", "parts", "for", "one", "or", "more", "parameters", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/docker_interface.py#L18-L40
train
spotify/docker_interface
docker_interface/docker_interface.py
build_dict_parameter_parts
def build_dict_parameter_parts(configuration, *parameters, **defaults): """ Construct command parts for one or more parameters, each of which constitutes an assignment of the form `key=value`. Parameters ---------- configuration : dict configuration parameters : list list of...
python
def build_dict_parameter_parts(configuration, *parameters, **defaults): """ Construct command parts for one or more parameters, each of which constitutes an assignment of the form `key=value`. Parameters ---------- configuration : dict configuration parameters : list list of...
[ "def", "build_dict_parameter_parts", "(", "configuration", ",", "*", "parameters", ",", "**", "defaults", ")", ":", "for", "parameter", "in", "parameters", ":", "for", "key", ",", "value", "in", "configuration", ".", "pop", "(", "parameter", ",", "{", "}", ...
Construct command parts for one or more parameters, each of which constitutes an assignment of the form `key=value`. Parameters ---------- configuration : dict configuration parameters : list list of parameters to create command line arguments for defaults : dict default...
[ "Construct", "command", "parts", "for", "one", "or", "more", "parameters", "each", "of", "which", "constitutes", "an", "assignment", "of", "the", "form", "key", "=", "value", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/docker_interface.py#L43-L64
train
spotify/docker_interface
docker_interface/docker_interface.py
build_docker_run_command
def build_docker_run_command(configuration): """ Translate a declarative docker `configuration` to a `docker run` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to run a command in a conta...
python
def build_docker_run_command(configuration): """ Translate a declarative docker `configuration` to a `docker run` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to run a command in a conta...
[ "def", "build_docker_run_command", "(", "configuration", ")", ":", "parts", "=", "configuration", ".", "pop", "(", "'docker'", ")", ".", "split", "(", ")", "parts", ".", "append", "(", "'run'", ")", "run", "=", "configuration", ".", "pop", "(", "'run'", ...
Translate a declarative docker `configuration` to a `docker run` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to run a command in a container
[ "Translate", "a", "declarative", "docker", "configuration", "to", "a", "docker", "run", "command", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/docker_interface.py#L67-L145
train
spotify/docker_interface
docker_interface/docker_interface.py
build_docker_build_command
def build_docker_build_command(configuration): """ Translate a declarative docker `configuration` to a `docker build` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to build an image "...
python
def build_docker_build_command(configuration): """ Translate a declarative docker `configuration` to a `docker build` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to build an image "...
[ "def", "build_docker_build_command", "(", "configuration", ")", ":", "parts", "=", "configuration", ".", "pop", "(", "'docker'", ",", "'docker'", ")", ".", "split", "(", ")", "parts", ".", "append", "(", "'build'", ")", "build", "=", "configuration", ".", ...
Translate a declarative docker `configuration` to a `docker build` command. Parameters ---------- configuration : dict configuration Returns ------- args : list sequence of command line arguments to build an image
[ "Translate", "a", "declarative", "docker", "configuration", "to", "a", "docker", "build", "command", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/docker_interface.py#L148-L176
train
spotify/docker_interface
docker_interface/plugins/base.py
Plugin.add_argument
def add_argument(self, parser, path, name=None, schema=None, **kwargs): """ Add an argument to the `parser` based on a schema definition. Parameters ---------- parser : argparse.ArgumentParser parser to add an argument to path : str path in the co...
python
def add_argument(self, parser, path, name=None, schema=None, **kwargs): """ Add an argument to the `parser` based on a schema definition. Parameters ---------- parser : argparse.ArgumentParser parser to add an argument to path : str path in the co...
[ "def", "add_argument", "(", "self", ",", "parser", ",", "path", ",", "name", "=", "None", ",", "schema", "=", "None", ",", "**", "kwargs", ")", ":", "schema", "=", "schema", "or", "self", ".", "SCHEMA", "name", "=", "name", "or", "(", "'--%s'", "%"...
Add an argument to the `parser` based on a schema definition. Parameters ---------- parser : argparse.ArgumentParser parser to add an argument to path : str path in the configuration document to add an argument for name : str or None name of t...
[ "Add", "an", "argument", "to", "the", "parser", "based", "on", "a", "schema", "definition", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/plugins/base.py#L42-L77
train
spotify/docker_interface
docker_interface/plugins/base.py
Plugin.apply
def apply(self, configuration, schema, args): """ Apply the plugin to the configuration. Inheriting plugins should implement this method to add additional functionality. Parameters ---------- configuration : dict configuration schema : dict ...
python
def apply(self, configuration, schema, args): """ Apply the plugin to the configuration. Inheriting plugins should implement this method to add additional functionality. Parameters ---------- configuration : dict configuration schema : dict ...
[ "def", "apply", "(", "self", ",", "configuration", ",", "schema", ",", "args", ")", ":", "for", "name", ",", "path", "in", "self", ".", "arguments", ".", "items", "(", ")", ":", "value", "=", "getattr", "(", "args", ",", "name", ".", "replace", "("...
Apply the plugin to the configuration. Inheriting plugins should implement this method to add additional functionality. Parameters ---------- configuration : dict configuration schema : dict JSON schema args : argparse.NameSpace parse...
[ "Apply", "the", "plugin", "to", "the", "configuration", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/plugins/base.py#L93-L119
train
spotify/docker_interface
docker_interface/plugins/base.py
Plugin.load_plugins
def load_plugins(): """ Load all availabe plugins. Returns ------- plugin_cls : dict mapping from plugin names to plugin classes """ plugin_cls = {} for entry_point in pkg_resources.iter_entry_points('docker_interface.plugins'): cl...
python
def load_plugins(): """ Load all availabe plugins. Returns ------- plugin_cls : dict mapping from plugin names to plugin classes """ plugin_cls = {} for entry_point in pkg_resources.iter_entry_points('docker_interface.plugins'): cl...
[ "def", "load_plugins", "(", ")", ":", "plugin_cls", "=", "{", "}", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'docker_interface.plugins'", ")", ":", "cls", "=", "entry_point", ".", "load", "(", ")", "assert", "cls", ".", "CO...
Load all availabe plugins. Returns ------- plugin_cls : dict mapping from plugin names to plugin classes
[ "Load", "all", "availabe", "plugins", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/plugins/base.py#L122-L139
train
spotify/docker_interface
docker_interface/plugins/base.py
SubstitutionPlugin.substitute_variables
def substitute_variables(cls, configuration, value, ref): """ Substitute variables in `value` from `configuration` where any path reference is relative to `ref`. Parameters ---------- configuration : dict configuration (required to resolve intra-document refe...
python
def substitute_variables(cls, configuration, value, ref): """ Substitute variables in `value` from `configuration` where any path reference is relative to `ref`. Parameters ---------- configuration : dict configuration (required to resolve intra-document refe...
[ "def", "substitute_variables", "(", "cls", ",", "configuration", ",", "value", ",", "ref", ")", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "while", "True", ":", "match", "=", "cls", ".", "REF_PATTERN", ".", "search", "(", "value", ")"...
Substitute variables in `value` from `configuration` where any path reference is relative to `ref`. Parameters ---------- configuration : dict configuration (required to resolve intra-document references) value : value to resolve substitutions for ...
[ "Substitute", "variables", "in", "value", "from", "configuration", "where", "any", "path", "reference", "is", "relative", "to", "ref", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/plugins/base.py#L347-L387
train
spotify/docker_interface
docker_interface/plugins/user.py
UserPlugin.get_user_group
def get_user_group(self, user=None, group=None): """ Get the user and group information. Parameters ---------- user : str User name or user id (default is the `os.getuid()`). group : str Group name or group id (default is the group of `user`). ...
python
def get_user_group(self, user=None, group=None): """ Get the user and group information. Parameters ---------- user : str User name or user id (default is the `os.getuid()`). group : str Group name or group id (default is the group of `user`). ...
[ "def", "get_user_group", "(", "self", ",", "user", "=", "None", ",", "group", "=", "None", ")", ":", "user", "=", "user", "or", "os", ".", "getuid", "(", ")", "try", ":", "try", ":", "user", "=", "pwd", ".", "getpwuid", "(", "int", "(", "user", ...
Get the user and group information. Parameters ---------- user : str User name or user id (default is the `os.getuid()`). group : str Group name or group id (default is the group of `user`). Returns ------- user : pwd.struct_passwd ...
[ "Get", "the", "user", "and", "group", "information", "." ]
4df80e1fe072d958020080d32c16551ff7703d51
https://github.com/spotify/docker_interface/blob/4df80e1fe072d958020080d32c16551ff7703d51/docker_interface/plugins/user.py#L60-L100
train
git-afsantos/bonsai
bonsai/model.py
pretty_str
def pretty_str(something, indent=0): """Return a human-readable string representation of an object. Uses `pretty_str` if the given value is an instance of `CodeEntity` and `repr` otherwise. Args: something: Some value to convert. Kwargs: indent (int): The amount of spaces ...
python
def pretty_str(something, indent=0): """Return a human-readable string representation of an object. Uses `pretty_str` if the given value is an instance of `CodeEntity` and `repr` otherwise. Args: something: Some value to convert. Kwargs: indent (int): The amount of spaces ...
[ "def", "pretty_str", "(", "something", ",", "indent", "=", "0", ")", ":", "if", "isinstance", "(", "something", ",", "CodeEntity", ")", ":", "return", "something", ".", "pretty_str", "(", "indent", "=", "indent", ")", "else", ":", "return", "(", "' '", ...
Return a human-readable string representation of an object. Uses `pretty_str` if the given value is an instance of `CodeEntity` and `repr` otherwise. Args: something: Some value to convert. Kwargs: indent (int): The amount of spaces to use as indentation.
[ "Return", "a", "human", "-", "readable", "string", "representation", "of", "an", "object", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1622-L1637
train
git-afsantos/bonsai
bonsai/model.py
CodeEntity.walk_preorder
def walk_preorder(self): """Iterates the program tree starting from this object, going down.""" yield self for child in self._children(): for descendant in child.walk_preorder(): yield descendant
python
def walk_preorder(self): """Iterates the program tree starting from this object, going down.""" yield self for child in self._children(): for descendant in child.walk_preorder(): yield descendant
[ "def", "walk_preorder", "(", "self", ")", ":", "yield", "self", "for", "child", "in", "self", ".", "_children", "(", ")", ":", "for", "descendant", "in", "child", ".", "walk_preorder", "(", ")", ":", "yield", "descendant" ]
Iterates the program tree starting from this object, going down.
[ "Iterates", "the", "program", "tree", "starting", "from", "this", "object", "going", "down", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L49-L54
train
git-afsantos/bonsai
bonsai/model.py
CodeEntity._lookup_parent
def _lookup_parent(self, cls): """Lookup a transitive parent object that is an instance of a given class.""" codeobj = self.parent while codeobj is not None and not isinstance(codeobj, cls): codeobj = codeobj.parent return codeobj
python
def _lookup_parent(self, cls): """Lookup a transitive parent object that is an instance of a given class.""" codeobj = self.parent while codeobj is not None and not isinstance(codeobj, cls): codeobj = codeobj.parent return codeobj
[ "def", "_lookup_parent", "(", "self", ",", "cls", ")", ":", "codeobj", "=", "self", ".", "parent", "while", "codeobj", "is", "not", "None", "and", "not", "isinstance", "(", "codeobj", ",", "cls", ")", ":", "codeobj", "=", "codeobj", ".", "parent", "ret...
Lookup a transitive parent object that is an instance of a given class.
[ "Lookup", "a", "transitive", "parent", "object", "that", "is", "an", "instance", "of", "a", "given", "class", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L87-L93
train
git-afsantos/bonsai
bonsai/model.py
CodeEntity.ast_str
def ast_str(self, indent=0): """Return a minimal string to print a tree-like structure. Kwargs: indent (int): The number of indentation levels. """ line = self.line or 0 col = self.column or 0 name = type(self).__name__ spell = getattr(self, 'name', '...
python
def ast_str(self, indent=0): """Return a minimal string to print a tree-like structure. Kwargs: indent (int): The number of indentation levels. """ line = self.line or 0 col = self.column or 0 name = type(self).__name__ spell = getattr(self, 'name', '...
[ "def", "ast_str", "(", "self", ",", "indent", "=", "0", ")", ":", "line", "=", "self", ".", "line", "or", "0", "col", "=", "self", ".", "column", "or", "0", "name", "=", "type", "(", "self", ")", ".", "__name__", "spell", "=", "getattr", "(", "...
Return a minimal string to print a tree-like structure. Kwargs: indent (int): The number of indentation levels.
[ "Return", "a", "minimal", "string", "to", "print", "a", "tree", "-", "like", "structure", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L103-L116
train
git-afsantos/bonsai
bonsai/model.py
CodeVariable.is_local
def is_local(self): """Whether this is a local variable. In general, a variable is *local* if its containing scope is a statement (e.g. a block), or a function, given that the variable is not one of the function's parameters. """ return (isinstance(self.scope...
python
def is_local(self): """Whether this is a local variable. In general, a variable is *local* if its containing scope is a statement (e.g. a block), or a function, given that the variable is not one of the function's parameters. """ return (isinstance(self.scope...
[ "def", "is_local", "(", "self", ")", ":", "return", "(", "isinstance", "(", "self", ".", "scope", ",", "CodeStatement", ")", "or", "(", "isinstance", "(", "self", ".", "scope", ",", "CodeFunction", ")", "and", "self", "not", "in", "self", ".", "scope",...
Whether this is a local variable. In general, a variable is *local* if its containing scope is a statement (e.g. a block), or a function, given that the variable is not one of the function's parameters.
[ "Whether", "this", "is", "a", "local", "variable", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L199-L208
train
git-afsantos/bonsai
bonsai/model.py
CodeVariable.is_parameter
def is_parameter(self): """Whether this is a function parameter.""" return (isinstance(self.scope, CodeFunction) and self in self.scope.parameters)
python
def is_parameter(self): """Whether this is a function parameter.""" return (isinstance(self.scope, CodeFunction) and self in self.scope.parameters)
[ "def", "is_parameter", "(", "self", ")", ":", "return", "(", "isinstance", "(", "self", ".", "scope", ",", "CodeFunction", ")", "and", "self", "in", "self", ".", "scope", ".", "parameters", ")" ]
Whether this is a function parameter.
[ "Whether", "this", "is", "a", "function", "parameter", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L220-L223
train
git-afsantos/bonsai
bonsai/model.py
CodeFunction._afterpass
def _afterpass(self): """Assign a function-local index to each child object and register write operations to variables. This should only be called after the object is fully built. """ if hasattr(self, '_fi'): return fi = 0 for codeobj in self....
python
def _afterpass(self): """Assign a function-local index to each child object and register write operations to variables. This should only be called after the object is fully built. """ if hasattr(self, '_fi'): return fi = 0 for codeobj in self....
[ "def", "_afterpass", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_fi'", ")", ":", "return", "fi", "=", "0", "for", "codeobj", "in", "self", ".", "walk_preorder", "(", ")", ":", "codeobj", ".", "_fi", "=", "fi", "fi", "+=", "1", "i...
Assign a function-local index to each child object and register write operations to variables. This should only be called after the object is fully built.
[ "Assign", "a", "function", "-", "local", "index", "to", "each", "child", "object", "and", "register", "write", "operations", "to", "variables", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L307-L324
train
git-afsantos/bonsai
bonsai/model.py
CodeControlFlow._set_condition
def _set_condition(self, condition): """Set the condition for this control flow structure.""" assert isinstance(condition, CodeExpression.TYPES) self.condition = condition
python
def _set_condition(self, condition): """Set the condition for this control flow structure.""" assert isinstance(condition, CodeExpression.TYPES) self.condition = condition
[ "def", "_set_condition", "(", "self", ",", "condition", ")", ":", "assert", "isinstance", "(", "condition", ",", "CodeExpression", ".", "TYPES", ")", "self", ".", "condition", "=", "condition" ]
Set the condition for this control flow structure.
[ "Set", "the", "condition", "for", "this", "control", "flow", "structure", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1261-L1264
train
git-afsantos/bonsai
bonsai/model.py
CodeControlFlow._set_body
def _set_body(self, body): """Set the main body for this control flow structure.""" assert isinstance(body, CodeStatement) if isinstance(body, CodeBlock): self.body = body else: self.body._add(body)
python
def _set_body(self, body): """Set the main body for this control flow structure.""" assert isinstance(body, CodeStatement) if isinstance(body, CodeBlock): self.body = body else: self.body._add(body)
[ "def", "_set_body", "(", "self", ",", "body", ")", ":", "assert", "isinstance", "(", "body", ",", "CodeStatement", ")", "if", "isinstance", "(", "body", ",", "CodeBlock", ")", ":", "self", ".", "body", "=", "body", "else", ":", "self", ".", "body", "...
Set the main body for this control flow structure.
[ "Set", "the", "main", "body", "for", "this", "control", "flow", "structure", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1266-L1272
train
git-afsantos/bonsai
bonsai/model.py
CodeConditional.get_branches
def get_branches(self): """Return a list with the conditional branch and the default branch.""" if self.else_branch: return [self.then_branch, self.else_branch] return [self.then_branch]
python
def get_branches(self): """Return a list with the conditional branch and the default branch.""" if self.else_branch: return [self.then_branch, self.else_branch] return [self.then_branch]
[ "def", "get_branches", "(", "self", ")", ":", "if", "self", ".", "else_branch", ":", "return", "[", "self", ".", "then_branch", ",", "self", ".", "else_branch", "]", "return", "[", "self", ".", "then_branch", "]" ]
Return a list with the conditional branch and the default branch.
[ "Return", "a", "list", "with", "the", "conditional", "branch", "and", "the", "default", "branch", "." ]
aa5af3f535b3b506bfc95c107c501fc9c4bcd072
https://github.com/git-afsantos/bonsai/blob/aa5af3f535b3b506bfc95c107c501fc9c4bcd072/bonsai/model.py#L1350-L1354
train
rehandalal/therapist
therapist/utils/filesystem.py
list_files
def list_files(path): """Recursively collects a list of files at a path.""" files = [] if os.path.isdir(path): for stats in os.walk(path): for f in stats[2]: files.append(os.path.join(stats[0], f)) elif os.path.isfile(path): files = [path] return files
python
def list_files(path): """Recursively collects a list of files at a path.""" files = [] if os.path.isdir(path): for stats in os.walk(path): for f in stats[2]: files.append(os.path.join(stats[0], f)) elif os.path.isfile(path): files = [path] return files
[ "def", "list_files", "(", "path", ")", ":", "files", "=", "[", "]", "if", "os", ".", "path", ".", "isdir", "(", "path", ")", ":", "for", "stats", "in", "os", ".", "walk", "(", "path", ")", ":", "for", "f", "in", "stats", "[", "2", "]", ":", ...
Recursively collects a list of files at a path.
[ "Recursively", "collects", "a", "list", "of", "files", "at", "a", "path", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/utils/filesystem.py#L14-L23
train
rehandalal/therapist
therapist/runner/result.py
ResultCollection.dump
def dump(self): """Returns the results in string format.""" text = '' for result in self.objects: if result.is_failure or result.is_error: text += '\n#{red}#{bright}' text += '{}\n'.format(''.ljust(79, '=')) status = 'FAILED' if resul...
python
def dump(self): """Returns the results in string format.""" text = '' for result in self.objects: if result.is_failure or result.is_error: text += '\n#{red}#{bright}' text += '{}\n'.format(''.ljust(79, '=')) status = 'FAILED' if resul...
[ "def", "dump", "(", "self", ")", ":", "text", "=", "''", "for", "result", "in", "self", ".", "objects", ":", "if", "result", ".", "is_failure", "or", "result", ".", "is_error", ":", "text", "+=", "'\\n#{red}#{bright}'", "text", "+=", "'{}\\n'", ".", "f...
Returns the results in string format.
[ "Returns", "the", "results", "in", "string", "format", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/runner/result.py#L145-L178
train
rehandalal/therapist
therapist/runner/result.py
ResultCollection.dump_junit
def dump_junit(self): """Returns a string containing XML mapped to the JUnit schema.""" testsuites = ElementTree.Element('testsuites', name='therapist', time=str(round(self.execution_time, 2)), tests=str(self.count()), failures=str(self.count(status=Result.FAILUR...
python
def dump_junit(self): """Returns a string containing XML mapped to the JUnit schema.""" testsuites = ElementTree.Element('testsuites', name='therapist', time=str(round(self.execution_time, 2)), tests=str(self.count()), failures=str(self.count(status=Result.FAILUR...
[ "def", "dump_junit", "(", "self", ")", ":", "testsuites", "=", "ElementTree", ".", "Element", "(", "'testsuites'", ",", "name", "=", "'therapist'", ",", "time", "=", "str", "(", "round", "(", "self", ".", "execution_time", ",", "2", ")", ")", ",", "tes...
Returns a string containing XML mapped to the JUnit schema.
[ "Returns", "a", "string", "containing", "XML", "mapped", "to", "the", "JUnit", "schema", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/runner/result.py#L180-L209
train
rehandalal/therapist
therapist/cli.py
install
def install(**kwargs): """Install the pre-commit hook.""" force = kwargs.get('force') preserve_legacy = kwargs.get('preserve_legacy') colorama.init(strip=kwargs.get('no_color')) stdout = subprocess.check_output('which therapist', shell=True) therapist_bin = stdout.decode('utf-8').split()[0] ...
python
def install(**kwargs): """Install the pre-commit hook.""" force = kwargs.get('force') preserve_legacy = kwargs.get('preserve_legacy') colorama.init(strip=kwargs.get('no_color')) stdout = subprocess.check_output('which therapist', shell=True) therapist_bin = stdout.decode('utf-8').split()[0] ...
[ "def", "install", "(", "**", "kwargs", ")", ":", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", "preserve_legacy", "=", "kwargs", ".", "get", "(", "'preserve_legacy'", ")", "colorama", ".", "init", "(", "strip", "=", "kwargs", ".", "get", "("...
Install the pre-commit hook.
[ "Install", "the", "pre", "-", "commit", "hook", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/cli.py#L80-L136
train
rehandalal/therapist
therapist/cli.py
uninstall
def uninstall(**kwargs): """Uninstall the current pre-commit hook.""" force = kwargs.get('force') restore_legacy = kwargs.get('restore_legacy') colorama.init(strip=kwargs.get('no_color')) git_dir = current_git_dir() if git_dir is None: output(NOT_GIT_REPO_MSG) exit(1) hoo...
python
def uninstall(**kwargs): """Uninstall the current pre-commit hook.""" force = kwargs.get('force') restore_legacy = kwargs.get('restore_legacy') colorama.init(strip=kwargs.get('no_color')) git_dir = current_git_dir() if git_dir is None: output(NOT_GIT_REPO_MSG) exit(1) hoo...
[ "def", "uninstall", "(", "**", "kwargs", ")", ":", "force", "=", "kwargs", ".", "get", "(", "'force'", ")", "restore_legacy", "=", "kwargs", ".", "get", "(", "'restore_legacy'", ")", "colorama", ".", "init", "(", "strip", "=", "kwargs", ".", "get", "("...
Uninstall the current pre-commit hook.
[ "Uninstall", "the", "current", "pre", "-", "commit", "hook", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/cli.py#L145-L195
train
rehandalal/therapist
therapist/cli.py
run
def run(**kwargs): """Run the Therapist suite.""" paths = kwargs.pop('paths', ()) action = kwargs.pop('action') plugin = kwargs.pop('plugin') junit_xml = kwargs.pop('junit_xml') use_tracked_files = kwargs.pop('use_tracked_files') quiet = kwargs.pop('quiet') colorama.init(strip=kwargs.po...
python
def run(**kwargs): """Run the Therapist suite.""" paths = kwargs.pop('paths', ()) action = kwargs.pop('action') plugin = kwargs.pop('plugin') junit_xml = kwargs.pop('junit_xml') use_tracked_files = kwargs.pop('use_tracked_files') quiet = kwargs.pop('quiet') colorama.init(strip=kwargs.po...
[ "def", "run", "(", "**", "kwargs", ")", ":", "paths", "=", "kwargs", ".", "pop", "(", "'paths'", ",", "(", ")", ")", "action", "=", "kwargs", ".", "pop", "(", "'action'", ")", "plugin", "=", "kwargs", ".", "pop", "(", "'plugin'", ")", "junit_xml", ...
Run the Therapist suite.
[ "Run", "the", "Therapist", "suite", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/cli.py#L211-L301
train
rehandalal/therapist
therapist/cli.py
use
def use(ctx, shortcut): """Use a shortcut.""" git_dir = current_git_dir() if git_dir is None: output(NOT_GIT_REPO_MSG) exit(1) repo_root = os.path.dirname(git_dir) config = get_config(repo_root) try: use_shortcut = config.shortcuts.get(shortcut) while use_sho...
python
def use(ctx, shortcut): """Use a shortcut.""" git_dir = current_git_dir() if git_dir is None: output(NOT_GIT_REPO_MSG) exit(1) repo_root = os.path.dirname(git_dir) config = get_config(repo_root) try: use_shortcut = config.shortcuts.get(shortcut) while use_sho...
[ "def", "use", "(", "ctx", ",", "shortcut", ")", ":", "git_dir", "=", "current_git_dir", "(", ")", "if", "git_dir", "is", "None", ":", "output", "(", "NOT_GIT_REPO_MSG", ")", "exit", "(", "1", ")", "repo_root", "=", "os", ".", "path", ".", "dirname", ...
Use a shortcut.
[ "Use", "a", "shortcut", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/cli.py#L307-L343
train
rehandalal/therapist
therapist/utils/hook.py
identify_hook
def identify_hook(path): """Verify that the file at path is the therapist hook and return the hash""" with open(path, 'r') as f: f.readline() # Discard the shebang line version_line = f.readline() if version_line.startswith('# THERAPIST'): return version_line.split()[2]
python
def identify_hook(path): """Verify that the file at path is the therapist hook and return the hash""" with open(path, 'r') as f: f.readline() # Discard the shebang line version_line = f.readline() if version_line.startswith('# THERAPIST'): return version_line.split()[2]
[ "def", "identify_hook", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "f", ":", "f", ".", "readline", "(", ")", "version_line", "=", "f", ".", "readline", "(", ")", "if", "version_line", ".", "startswith", "(", "'# THERAP...
Verify that the file at path is the therapist hook and return the hash
[ "Verify", "that", "the", "file", "at", "path", "is", "the", "therapist", "hook", "and", "return", "the", "hash" ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/utils/hook.py#L6-L12
train
rehandalal/therapist
therapist/utils/hook.py
hash_hook
def hash_hook(path, options): """Hash a hook file""" with open(path, 'r') as f: data = f.read() for key in sorted(iterkeys(options)): data += '\n#{}={}'.format(key, options.get(key)) return hashlib.md5(data.encode()).hexdigest()
python
def hash_hook(path, options): """Hash a hook file""" with open(path, 'r') as f: data = f.read() for key in sorted(iterkeys(options)): data += '\n#{}={}'.format(key, options.get(key)) return hashlib.md5(data.encode()).hexdigest()
[ "def", "hash_hook", "(", "path", ",", "options", ")", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "f", ":", "data", "=", "f", ".", "read", "(", ")", "for", "key", "in", "sorted", "(", "iterkeys", "(", "options", ")", ")", ":", "dat...
Hash a hook file
[ "Hash", "a", "hook", "file" ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/utils/hook.py#L15-L21
train
rehandalal/therapist
therapist/runner/runner.py
Runner.run_process
def run_process(self, process): """Runs a single action.""" message = u'#{bright}' message += u'{} '.format(str(process)[:68]).ljust(69, '.') stashed = False if self.unstaged_changes and not self.include_unstaged_changes: out, err, code = self.git.stash(keep_index=Tr...
python
def run_process(self, process): """Runs a single action.""" message = u'#{bright}' message += u'{} '.format(str(process)[:68]).ljust(69, '.') stashed = False if self.unstaged_changes and not self.include_unstaged_changes: out, err, code = self.git.stash(keep_index=Tr...
[ "def", "run_process", "(", "self", ",", "process", ")", ":", "message", "=", "u'#{bright}'", "message", "+=", "u'{} '", ".", "format", "(", "str", "(", "process", ")", "[", ":", "68", "]", ")", ".", "ljust", "(", "69", ",", "'.'", ")", "stashed", "...
Runs a single action.
[ "Runs", "a", "single", "action", "." ]
1995a7e396eea2ec8685bb32a779a4110b459b1f
https://github.com/rehandalal/therapist/blob/1995a7e396eea2ec8685bb32a779a4110b459b1f/therapist/runner/runner.py#L47-L90
train
flyte/upnpclient
upnpclient/soap.py
SOAP._extract_upnperror
def _extract_upnperror(self, err_xml): """ Extract the error code and error description from an error returned by the device. """ nsmap = {'s': list(err_xml.nsmap.values())[0]} fault_str = err_xml.findtext( 's:Body/s:Fault/faultstring', namespaces=nsmap) try: ...
python
def _extract_upnperror(self, err_xml): """ Extract the error code and error description from an error returned by the device. """ nsmap = {'s': list(err_xml.nsmap.values())[0]} fault_str = err_xml.findtext( 's:Body/s:Fault/faultstring', namespaces=nsmap) try: ...
[ "def", "_extract_upnperror", "(", "self", ",", "err_xml", ")", ":", "nsmap", "=", "{", "'s'", ":", "list", "(", "err_xml", ".", "nsmap", ".", "values", "(", ")", ")", "[", "0", "]", "}", "fault_str", "=", "err_xml", ".", "findtext", "(", "'s:Body/s:F...
Extract the error code and error description from an error returned by the device.
[ "Extract", "the", "error", "code", "and", "error", "description", "from", "an", "error", "returned", "by", "the", "device", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/soap.py#L35-L59
train
flyte/upnpclient
upnpclient/soap.py
SOAP._remove_extraneous_xml_declarations
def _remove_extraneous_xml_declarations(xml_str): """ Sometimes devices return XML with more than one XML declaration in, such as when returning their own XML config files. This removes the extra ones and preserves the first one. """ xml_declaration = '' if xml_str.starts...
python
def _remove_extraneous_xml_declarations(xml_str): """ Sometimes devices return XML with more than one XML declaration in, such as when returning their own XML config files. This removes the extra ones and preserves the first one. """ xml_declaration = '' if xml_str.starts...
[ "def", "_remove_extraneous_xml_declarations", "(", "xml_str", ")", ":", "xml_declaration", "=", "''", "if", "xml_str", ".", "startswith", "(", "'<?xml'", ")", ":", "xml_declaration", ",", "xml_str", "=", "xml_str", ".", "split", "(", "'?>'", ",", "maxsplit", "...
Sometimes devices return XML with more than one XML declaration in, such as when returning their own XML config files. This removes the extra ones and preserves the first one.
[ "Sometimes", "devices", "return", "XML", "with", "more", "than", "one", "XML", "declaration", "in", "such", "as", "when", "returning", "their", "own", "XML", "config", "files", ".", "This", "removes", "the", "extra", "ones", "and", "preserves", "the", "first...
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/soap.py#L62-L72
train
flyte/upnpclient
upnpclient/soap.py
SOAP.call
def call(self, action_name, arg_in=None, http_auth=None, http_headers=None): """ Construct the XML and make the call to the device. Parse the response values into a dict. """ if arg_in is None: arg_in = {} soap_env = '{%s}' % NS_SOAP_ENV m = '{%s}' % self.ser...
python
def call(self, action_name, arg_in=None, http_auth=None, http_headers=None): """ Construct the XML and make the call to the device. Parse the response values into a dict. """ if arg_in is None: arg_in = {} soap_env = '{%s}' % NS_SOAP_ENV m = '{%s}' % self.ser...
[ "def", "call", "(", "self", ",", "action_name", ",", "arg_in", "=", "None", ",", "http_auth", "=", "None", ",", "http_headers", "=", "None", ")", ":", "if", "arg_in", "is", "None", ":", "arg_in", "=", "{", "}", "soap_env", "=", "'{%s}'", "%", "NS_SOA...
Construct the XML and make the call to the device. Parse the response values into a dict.
[ "Construct", "the", "XML", "and", "make", "the", "call", "to", "the", "device", ".", "Parse", "the", "response", "values", "into", "a", "dict", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/soap.py#L74-L146
train
flyte/upnpclient
upnpclient/upnp.py
Device._read_services
def _read_services(self): """ Read the control XML file and populate self.services with a list of services in the form of Service class instances. """ # The double slash in the XPath is deliberate, as services can be # listed in two places (Section 2.3 of uPNP device arch...
python
def _read_services(self): """ Read the control XML file and populate self.services with a list of services in the form of Service class instances. """ # The double slash in the XPath is deliberate, as services can be # listed in two places (Section 2.3 of uPNP device arch...
[ "def", "_read_services", "(", "self", ")", ":", "for", "node", "in", "self", ".", "_findall", "(", "'device//serviceList/service'", ")", ":", "findtext", "=", "partial", "(", "node", ".", "findtext", ",", "namespaces", "=", "self", ".", "_root_xml", ".", "...
Read the control XML file and populate self.services with a list of services in the form of Service class instances.
[ "Read", "the", "control", "XML", "file", "and", "populate", "self", ".", "services", "with", "a", "list", "of", "services", "in", "the", "form", "of", "Service", "class", "instances", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/upnp.py#L164-L185
train
flyte/upnpclient
upnpclient/upnp.py
Device.find_action
def find_action(self, action_name): """Find an action by name. Convenience method that searches through all the services offered by the Server for an action and returns an Action instance. If the action is not found, returns None. If multiple actions with the same name are found ...
python
def find_action(self, action_name): """Find an action by name. Convenience method that searches through all the services offered by the Server for an action and returns an Action instance. If the action is not found, returns None. If multiple actions with the same name are found ...
[ "def", "find_action", "(", "self", ",", "action_name", ")", ":", "for", "service", "in", "self", ".", "services", ":", "action", "=", "service", ".", "find_action", "(", "action_name", ")", "if", "action", "is", "not", "None", ":", "return", "action" ]
Find an action by name. Convenience method that searches through all the services offered by the Server for an action and returns an Action instance. If the action is not found, returns None. If multiple actions with the same name are found it returns the first one.
[ "Find", "an", "action", "by", "name", ".", "Convenience", "method", "that", "searches", "through", "all", "the", "services", "offered", "by", "the", "Server", "for", "an", "action", "and", "returns", "an", "Action", "instance", ".", "If", "the", "action", ...
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/upnp.py#L187-L197
train
flyte/upnpclient
upnpclient/upnp.py
Service.subscribe
def subscribe(self, callback_url, timeout=None): """ Set up a subscription to the events offered by this service. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, CALLBACK='<%s>' % callback_url, ...
python
def subscribe(self, callback_url, timeout=None): """ Set up a subscription to the events offered by this service. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, CALLBACK='<%s>' % callback_url, ...
[ "def", "subscribe", "(", "self", ",", "callback_url", ",", "timeout", "=", "None", ")", ":", "url", "=", "urljoin", "(", "self", ".", "_url_base", ",", "self", ".", "_event_sub_url", ")", "headers", "=", "dict", "(", "HOST", "=", "urlparse", "(", "url"...
Set up a subscription to the events offered by this service.
[ "Set", "up", "a", "subscription", "to", "the", "events", "offered", "by", "this", "service", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/upnp.py#L357-L371
train
flyte/upnpclient
upnpclient/upnp.py
Service.renew_subscription
def renew_subscription(self, sid, timeout=None): """ Renews a previously configured subscription. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, SID=sid ) if timeout is not None: ...
python
def renew_subscription(self, sid, timeout=None): """ Renews a previously configured subscription. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, SID=sid ) if timeout is not None: ...
[ "def", "renew_subscription", "(", "self", ",", "sid", ",", "timeout", "=", "None", ")", ":", "url", "=", "urljoin", "(", "self", ".", "_url_base", ",", "self", ".", "_event_sub_url", ")", "headers", "=", "dict", "(", "HOST", "=", "urlparse", "(", "url"...
Renews a previously configured subscription.
[ "Renews", "a", "previously", "configured", "subscription", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/upnp.py#L373-L386
train
flyte/upnpclient
upnpclient/upnp.py
Service.cancel_subscription
def cancel_subscription(self, sid): """ Unsubscribes from a previously configured subscription. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, SID=sid ) resp = requests.request('UNSUBSCRIBE...
python
def cancel_subscription(self, sid): """ Unsubscribes from a previously configured subscription. """ url = urljoin(self._url_base, self._event_sub_url) headers = dict( HOST=urlparse(url).netloc, SID=sid ) resp = requests.request('UNSUBSCRIBE...
[ "def", "cancel_subscription", "(", "self", ",", "sid", ")", ":", "url", "=", "urljoin", "(", "self", ".", "_url_base", ",", "self", ".", "_event_sub_url", ")", "headers", "=", "dict", "(", "HOST", "=", "urlparse", "(", "url", ")", ".", "netloc", ",", ...
Unsubscribes from a previously configured subscription.
[ "Unsubscribes", "from", "a", "previously", "configured", "subscription", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/upnp.py#L388-L398
train
flyte/upnpclient
upnpclient/ssdp.py
discover
def discover(timeout=5): """ Convenience method to discover UPnP devices on the network. Returns a list of `upnp.Device` instances. Any invalid servers are silently ignored. """ devices = {} for entry in scan(timeout): if entry.location in devices: continue try: ...
python
def discover(timeout=5): """ Convenience method to discover UPnP devices on the network. Returns a list of `upnp.Device` instances. Any invalid servers are silently ignored. """ devices = {} for entry in scan(timeout): if entry.location in devices: continue try: ...
[ "def", "discover", "(", "timeout", "=", "5", ")", ":", "devices", "=", "{", "}", "for", "entry", "in", "scan", "(", "timeout", ")", ":", "if", "entry", ".", "location", "in", "devices", ":", "continue", "try", ":", "devices", "[", "entry", ".", "lo...
Convenience method to discover UPnP devices on the network. Returns a list of `upnp.Device` instances. Any invalid servers are silently ignored.
[ "Convenience", "method", "to", "discover", "UPnP", "devices", "on", "the", "network", ".", "Returns", "a", "list", "of", "upnp", ".", "Device", "instances", ".", "Any", "invalid", "servers", "are", "silently", "ignored", "." ]
5529b950df33c0eaf0c24a9a307cf00fe627d0ad
https://github.com/flyte/upnpclient/blob/5529b950df33c0eaf0c24a9a307cf00fe627d0ad/upnpclient/ssdp.py#L7-L22
train
MarcoFavorito/pythomata
pythomata/dfa.py
DFA.to_dot
def to_dot(self, path: str, title: Optional[str] = None): """ Print the automaton to a dot file :param path: the path where to save the file. :param title: :return: """ g = graphviz.Digraph(format='svg') g.node('fake', style='invisible') for state...
python
def to_dot(self, path: str, title: Optional[str] = None): """ Print the automaton to a dot file :param path: the path where to save the file. :param title: :return: """ g = graphviz.Digraph(format='svg') g.node('fake', style='invisible') for state...
[ "def", "to_dot", "(", "self", ",", "path", ":", "str", ",", "title", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "g", "=", "graphviz", ".", "Digraph", "(", "format", "=", "'svg'", ")", "g", ".", "node", "(", "'fake'", ",", "style", ...
Print the automaton to a dot file :param path: the path where to save the file. :param title: :return:
[ "Print", "the", "automaton", "to", "a", "dot", "file" ]
4739c620008b8fe50583eecb97f9bfd7f006b95c
https://github.com/MarcoFavorito/pythomata/blob/4739c620008b8fe50583eecb97f9bfd7f006b95c/pythomata/dfa.py#L248-L282
train
MarcoFavorito/pythomata
pythomata/dfa.py
DFA.levels_to_accepting_states
def levels_to_accepting_states(self) -> dict: """Return a dict from states to level, i.e. the number of steps to reach any accepting state. level = -1 if the state cannot reach any accepting state""" res = {accepting_state: 0 for accepting_state in self._accepting_states} level = 0 ...
python
def levels_to_accepting_states(self) -> dict: """Return a dict from states to level, i.e. the number of steps to reach any accepting state. level = -1 if the state cannot reach any accepting state""" res = {accepting_state: 0 for accepting_state in self._accepting_states} level = 0 ...
[ "def", "levels_to_accepting_states", "(", "self", ")", "->", "dict", ":", "res", "=", "{", "accepting_state", ":", "0", "for", "accepting_state", "in", "self", ".", "_accepting_states", "}", "level", "=", "0", "z_current", ",", "z_next", "=", "set", "(", "...
Return a dict from states to level, i.e. the number of steps to reach any accepting state. level = -1 if the state cannot reach any accepting state
[ "Return", "a", "dict", "from", "states", "to", "level", "i", ".", "e", ".", "the", "number", "of", "steps", "to", "reach", "any", "accepting", "state", ".", "level", "=", "-", "1", "if", "the", "state", "cannot", "reach", "any", "accepting", "state" ]
4739c620008b8fe50583eecb97f9bfd7f006b95c
https://github.com/MarcoFavorito/pythomata/blob/4739c620008b8fe50583eecb97f9bfd7f006b95c/pythomata/dfa.py#L284-L313
train
MarcoFavorito/pythomata
pythomata/nfa.py
NFA.determinize
def determinize(self) -> DFA: """Determinize the NFA :return: the DFA equivalent to the DFA. """ nfa = self new_states = {macro_state for macro_state in powerset(nfa._states)} initial_state = frozenset([nfa._initial_state]) final_states = {q for q in new_states...
python
def determinize(self) -> DFA: """Determinize the NFA :return: the DFA equivalent to the DFA. """ nfa = self new_states = {macro_state for macro_state in powerset(nfa._states)} initial_state = frozenset([nfa._initial_state]) final_states = {q for q in new_states...
[ "def", "determinize", "(", "self", ")", "->", "DFA", ":", "nfa", "=", "self", "new_states", "=", "{", "macro_state", "for", "macro_state", "in", "powerset", "(", "nfa", ".", "_states", ")", "}", "initial_state", "=", "frozenset", "(", "[", "nfa", ".", ...
Determinize the NFA :return: the DFA equivalent to the DFA.
[ "Determinize", "the", "NFA" ]
4739c620008b8fe50583eecb97f9bfd7f006b95c
https://github.com/MarcoFavorito/pythomata/blob/4739c620008b8fe50583eecb97f9bfd7f006b95c/pythomata/nfa.py#L100-L124
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.req
def req(self, method, params=()): """send request to ppcoind""" response = self.session.post( self.url, data=json.dumps({"method": method, "params": params, "jsonrpc": "1.1"}), ).json() if response["error"] is not None: return response["error"] ...
python
def req(self, method, params=()): """send request to ppcoind""" response = self.session.post( self.url, data=json.dumps({"method": method, "params": params, "jsonrpc": "1.1"}), ).json() if response["error"] is not None: return response["error"] ...
[ "def", "req", "(", "self", ",", "method", ",", "params", "=", "(", ")", ")", ":", "response", "=", "self", ".", "session", ".", "post", "(", "self", ".", "url", ",", "data", "=", "json", ".", "dumps", "(", "{", "\"method\"", ":", "method", ",", ...
send request to ppcoind
[ "send", "request", "to", "ppcoind" ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L85-L96
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.batch
def batch(self, reqs): """ send batch request using jsonrpc 2.0 """ batch_data = [] for req_id, req in enumerate(reqs): batch_data.append( {"method": req[0], "params": req[1], "jsonrpc": "2.0", "id": req_id} ) data = json.dumps(batch_data) ...
python
def batch(self, reqs): """ send batch request using jsonrpc 2.0 """ batch_data = [] for req_id, req in enumerate(reqs): batch_data.append( {"method": req[0], "params": req[1], "jsonrpc": "2.0", "id": req_id} ) data = json.dumps(batch_data) ...
[ "def", "batch", "(", "self", ",", "reqs", ")", ":", "batch_data", "=", "[", "]", "for", "req_id", ",", "req", "in", "enumerate", "(", "reqs", ")", ":", "batch_data", ".", "append", "(", "{", "\"method\"", ":", "req", "[", "0", "]", ",", "\"params\"...
send batch request using jsonrpc 2.0
[ "send", "batch", "request", "using", "jsonrpc", "2", ".", "0" ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L98-L110
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.walletpassphrase
def walletpassphrase(self, passphrase, timeout=99999999, mint_only=True): """used to unlock wallet for minting""" return self.req("walletpassphrase", [passphrase, timeout, mint_only])
python
def walletpassphrase(self, passphrase, timeout=99999999, mint_only=True): """used to unlock wallet for minting""" return self.req("walletpassphrase", [passphrase, timeout, mint_only])
[ "def", "walletpassphrase", "(", "self", ",", "passphrase", ",", "timeout", "=", "99999999", ",", "mint_only", "=", "True", ")", ":", "return", "self", ".", "req", "(", "\"walletpassphrase\"", ",", "[", "passphrase", ",", "timeout", ",", "mint_only", "]", "...
used to unlock wallet for minting
[ "used", "to", "unlock", "wallet", "for", "minting" ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L119-L121
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.getblock
def getblock(self, blockhash, decode=False): """returns detail block info.""" if not decode: decode = "false" return self.req("getblock", [blockhash, decode]) else: return self.req("getblock", [blockhash])
python
def getblock(self, blockhash, decode=False): """returns detail block info.""" if not decode: decode = "false" return self.req("getblock", [blockhash, decode]) else: return self.req("getblock", [blockhash])
[ "def", "getblock", "(", "self", ",", "blockhash", ",", "decode", "=", "False", ")", ":", "if", "not", "decode", ":", "decode", "=", "\"false\"", "return", "self", ".", "req", "(", "\"getblock\"", ",", "[", "blockhash", ",", "decode", "]", ")", "else", ...
returns detail block info.
[ "returns", "detail", "block", "info", "." ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L123-L132
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.sendfrom
def sendfrom(self, account, address, amount): """send outgoing tx from specified account to a given address""" return self.req("sendfrom", [account, address, amount])
python
def sendfrom(self, account, address, amount): """send outgoing tx from specified account to a given address""" return self.req("sendfrom", [account, address, amount])
[ "def", "sendfrom", "(", "self", ",", "account", ",", "address", ",", "amount", ")", ":", "return", "self", ".", "req", "(", "\"sendfrom\"", ",", "[", "account", ",", "address", ",", "amount", "]", ")" ]
send outgoing tx from specified account to a given address
[ "send", "outgoing", "tx", "from", "specified", "account", "to", "a", "given", "address" ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L187-L189
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.listtransactions
def listtransactions(self, account="", many=999, since=0): """list all transactions associated with this wallet""" return self.req("listtransactions", [account, many, since])
python
def listtransactions(self, account="", many=999, since=0): """list all transactions associated with this wallet""" return self.req("listtransactions", [account, many, since])
[ "def", "listtransactions", "(", "self", ",", "account", "=", "\"\"", ",", "many", "=", "999", ",", "since", "=", "0", ")", ":", "return", "self", ".", "req", "(", "\"listtransactions\"", ",", "[", "account", ",", "many", ",", "since", "]", ")" ]
list all transactions associated with this wallet
[ "list", "all", "transactions", "associated", "with", "this", "wallet" ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L211-L213
train
peercoin/peercoin_rpc
peercoin_rpc/peercoin_rpc.py
Client.verifymessage
def verifymessage(self, address, signature, message): """Verify a signed message.""" return self.req("verifymessage", [address, signature, message])
python
def verifymessage(self, address, signature, message): """Verify a signed message.""" return self.req("verifymessage", [address, signature, message])
[ "def", "verifymessage", "(", "self", ",", "address", ",", "signature", ",", "message", ")", ":", "return", "self", ".", "req", "(", "\"verifymessage\"", ",", "[", "address", ",", "signature", ",", "message", "]", ")" ]
Verify a signed message.
[ "Verify", "a", "signed", "message", "." ]
6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc
https://github.com/peercoin/peercoin_rpc/blob/6edd854c7fd607ad9f6f4d5eb8b8b7c7fd8c16cc/peercoin_rpc/peercoin_rpc.py#L277-L279
train
NLeSC/noodles
noodles/lib/coroutine.py
coroutine
def coroutine(f): """ A sink should be send `None` first, so that the coroutine arrives at the `yield` position. This wrapper takes care that this is done automatically when the coroutine is started. """ @wraps(f) def g(*args, **kwargs): sink = f(*args, **kwargs) sink.send(No...
python
def coroutine(f): """ A sink should be send `None` first, so that the coroutine arrives at the `yield` position. This wrapper takes care that this is done automatically when the coroutine is started. """ @wraps(f) def g(*args, **kwargs): sink = f(*args, **kwargs) sink.send(No...
[ "def", "coroutine", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "g", "(", "*", "args", ",", "**", "kwargs", ")", ":", "sink", "=", "f", "(", "*", "args", ",", "**", "kwargs", ")", "sink", ".", "send", "(", "None", ")", "return", ...
A sink should be send `None` first, so that the coroutine arrives at the `yield` position. This wrapper takes care that this is done automatically when the coroutine is started.
[ "A", "sink", "should", "be", "send", "None", "first", "so", "that", "the", "coroutine", "arrives", "at", "the", "yield", "position", ".", "This", "wrapper", "takes", "care", "that", "this", "is", "done", "automatically", "when", "the", "coroutine", "is", "...
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/lib/coroutine.py#L4-L16
train
NLeSC/noodles
noodles/interface/maybe.py
Fail.add_call
def add_call(self, func): """Add a call to the trace.""" self.trace.append("{} ({}:{})".format( object_name(func), inspect.getsourcefile(func), inspect.getsourcelines(func)[1])) return self
python
def add_call(self, func): """Add a call to the trace.""" self.trace.append("{} ({}:{})".format( object_name(func), inspect.getsourcefile(func), inspect.getsourcelines(func)[1])) return self
[ "def", "add_call", "(", "self", ",", "func", ")", ":", "self", ".", "trace", ".", "append", "(", "\"{} ({}:{})\"", ".", "format", "(", "object_name", "(", "func", ")", ",", "inspect", ".", "getsourcefile", "(", "func", ")", ",", "inspect", ".", "getsou...
Add a call to the trace.
[ "Add", "a", "call", "to", "the", "trace", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/interface/maybe.py#L33-L40
train
NLeSC/noodles
noodles/patterns/functional_patterns.py
all
def all(pred: Callable, xs: Iterable): """ Check whether all the elements of the iterable `xs` fullfill predicate `pred`. :param pred: predicate function :param xs: iterable object. :returns: boolean """ for x in xs: if not pred(x): return False re...
python
def all(pred: Callable, xs: Iterable): """ Check whether all the elements of the iterable `xs` fullfill predicate `pred`. :param pred: predicate function :param xs: iterable object. :returns: boolean """ for x in xs: if not pred(x): return False re...
[ "def", "all", "(", "pred", ":", "Callable", ",", "xs", ":", "Iterable", ")", ":", "for", "x", "in", "xs", ":", "if", "not", "pred", "(", "x", ")", ":", "return", "False", "return", "True" ]
Check whether all the elements of the iterable `xs` fullfill predicate `pred`. :param pred: predicate function :param xs: iterable object. :returns: boolean
[ "Check", "whether", "all", "the", "elements", "of", "the", "iterable", "xs", "fullfill", "predicate", "pred", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/patterns/functional_patterns.py#L7-L22
train
NLeSC/noodles
noodles/patterns/functional_patterns.py
any
def any(pred: Callable, xs: Iterable): """ Check if at least one element of the iterable `xs` fullfills predicate `pred`. :param pred: predicate function. :param xs: iterable object. :returns: boolean """ b = find_first(pred, xs) return True if b is not None else Fals...
python
def any(pred: Callable, xs: Iterable): """ Check if at least one element of the iterable `xs` fullfills predicate `pred`. :param pred: predicate function. :param xs: iterable object. :returns: boolean """ b = find_first(pred, xs) return True if b is not None else Fals...
[ "def", "any", "(", "pred", ":", "Callable", ",", "xs", ":", "Iterable", ")", ":", "b", "=", "find_first", "(", "pred", ",", "xs", ")", "return", "True", "if", "b", "is", "not", "None", "else", "False" ]
Check if at least one element of the iterable `xs` fullfills predicate `pred`. :param pred: predicate function. :param xs: iterable object. :returns: boolean
[ "Check", "if", "at", "least", "one", "element", "of", "the", "iterable", "xs", "fullfills", "predicate", "pred", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/patterns/functional_patterns.py#L26-L39
train
NLeSC/noodles
noodles/patterns/functional_patterns.py
map
def map(fun: Callable, xs: Iterable): """ Traverse an iterable object applying function `fun` to each element and finally creats a workflow from it. :param fun: function to call in each element of the iterable object. :param xs: Iterable object. returns::py:class:`PromisedObj...
python
def map(fun: Callable, xs: Iterable): """ Traverse an iterable object applying function `fun` to each element and finally creats a workflow from it. :param fun: function to call in each element of the iterable object. :param xs: Iterable object. returns::py:class:`PromisedObj...
[ "def", "map", "(", "fun", ":", "Callable", ",", "xs", ":", "Iterable", ")", ":", "generator", "=", "(", "fun", "(", "x", ")", "for", "x", "in", "xs", ")", "return", "gather", "(", "*", "generator", ")" ]
Traverse an iterable object applying function `fun` to each element and finally creats a workflow from it. :param fun: function to call in each element of the iterable object. :param xs: Iterable object. returns::py:class:`PromisedObject`
[ "Traverse", "an", "iterable", "object", "applying", "function", "fun", "to", "each", "element", "and", "finally", "creats", "a", "workflow", "from", "it", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/patterns/functional_patterns.py#L82-L97
train
NLeSC/noodles
noodles/patterns/functional_patterns.py
zip_with
def zip_with(fun: Callable, xs: Iterable, ys: Iterable): """ Fuse two Iterable object using the function `fun`. Notice that if the two objects have different len, the shortest object gives the result's shape. :param fun: function taking two argument use to process element x from `xs` ...
python
def zip_with(fun: Callable, xs: Iterable, ys: Iterable): """ Fuse two Iterable object using the function `fun`. Notice that if the two objects have different len, the shortest object gives the result's shape. :param fun: function taking two argument use to process element x from `xs` ...
[ "def", "zip_with", "(", "fun", ":", "Callable", ",", "xs", ":", "Iterable", ",", "ys", ":", "Iterable", ")", ":", "generator", "=", "(", "fun", "(", "*", "rs", ")", "for", "rs", "in", "zip", "(", "xs", ",", "ys", ")", ")", "return", "gather", "...
Fuse two Iterable object using the function `fun`. Notice that if the two objects have different len, the shortest object gives the result's shape. :param fun: function taking two argument use to process element x from `xs` and y from `ys`. :param xs: first iterable. :param y...
[ "Fuse", "two", "Iterable", "object", "using", "the", "function", "fun", ".", "Notice", "that", "if", "the", "two", "objects", "have", "different", "len", "the", "shortest", "object", "gives", "the", "result", "s", "shape", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/patterns/functional_patterns.py#L101-L121
train
NLeSC/noodles
noodles/workflow/model.py
_arg_to_str
def _arg_to_str(arg): """Convert argument to a string.""" if isinstance(arg, str): return _sugar(repr(arg)) elif arg is Empty: return '\u2014' else: return _sugar(str(arg))
python
def _arg_to_str(arg): """Convert argument to a string.""" if isinstance(arg, str): return _sugar(repr(arg)) elif arg is Empty: return '\u2014' else: return _sugar(str(arg))
[ "def", "_arg_to_str", "(", "arg", ")", ":", "if", "isinstance", "(", "arg", ",", "str", ")", ":", "return", "_sugar", "(", "repr", "(", "arg", ")", ")", "elif", "arg", "is", "Empty", ":", "return", "'\\u2014'", "else", ":", "return", "_sugar", "(", ...
Convert argument to a string.
[ "Convert", "argument", "to", "a", "string", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/workflow/model.py#L19-L26
train
NLeSC/noodles
noodles/workflow/model.py
is_node_ready
def is_node_ready(node): """Returns True if none of the argument holders contain any `Empty` object. """ return all(ref_argument(node.bound_args, a) is not Empty for a in serialize_arguments(node.bound_args))
python
def is_node_ready(node): """Returns True if none of the argument holders contain any `Empty` object. """ return all(ref_argument(node.bound_args, a) is not Empty for a in serialize_arguments(node.bound_args))
[ "def", "is_node_ready", "(", "node", ")", ":", "return", "all", "(", "ref_argument", "(", "node", ".", "bound_args", ",", "a", ")", "is", "not", "Empty", "for", "a", "in", "serialize_arguments", "(", "node", ".", "bound_args", ")", ")" ]
Returns True if none of the argument holders contain any `Empty` object.
[ "Returns", "True", "if", "none", "of", "the", "argument", "holders", "contain", "any", "Empty", "object", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/workflow/model.py#L137-L141
train
NLeSC/noodles
noodles/prov/sqlite.py
JobDB.add_job_to_db
def add_job_to_db(self, key, job): """Add job info to the database.""" job_msg = self.registry.deep_encode(job) prov = prov_key(job_msg) def set_link(duplicate_id): self.cur.execute( 'update "jobs" set "link" = ?, "status" = ? where "id" = ?', ...
python
def add_job_to_db(self, key, job): """Add job info to the database.""" job_msg = self.registry.deep_encode(job) prov = prov_key(job_msg) def set_link(duplicate_id): self.cur.execute( 'update "jobs" set "link" = ?, "status" = ? where "id" = ?', ...
[ "def", "add_job_to_db", "(", "self", ",", "key", ",", "job", ")", ":", "job_msg", "=", "self", ".", "registry", ".", "deep_encode", "(", "job", ")", "prov", "=", "prov_key", "(", "job_msg", ")", "def", "set_link", "(", "duplicate_id", ")", ":", "self",...
Add job info to the database.
[ "Add", "job", "info", "to", "the", "database", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/prov/sqlite.py#L245-L307
train
NLeSC/noodles
noodles/prov/sqlite.py
JobDB.job_exists
def job_exists(self, prov): """Check if a job exists in the database.""" with self.lock: self.cur.execute('select * from "jobs" where "prov" = ?;', (prov,)) rec = self.cur.fetchone() return rec is not None
python
def job_exists(self, prov): """Check if a job exists in the database.""" with self.lock: self.cur.execute('select * from "jobs" where "prov" = ?;', (prov,)) rec = self.cur.fetchone() return rec is not None
[ "def", "job_exists", "(", "self", ",", "prov", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "cur", ".", "execute", "(", "'select * from \"jobs\" where \"prov\" = ?;'", ",", "(", "prov", ",", ")", ")", "rec", "=", "self", ".", "cur", ".", "f...
Check if a job exists in the database.
[ "Check", "if", "a", "job", "exists", "in", "the", "database", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/prov/sqlite.py#L309-L314
train
NLeSC/noodles
noodles/prov/sqlite.py
JobDB.store_result_in_db
def store_result_in_db(self, result, always_cache=True): """Store a result in the database.""" job = self[result.key] def extend_dependent_links(): with self.lock: new_workflow_id = id(get_workflow(result.value)) self.links[new_workflow_id].extend( ...
python
def store_result_in_db(self, result, always_cache=True): """Store a result in the database.""" job = self[result.key] def extend_dependent_links(): with self.lock: new_workflow_id = id(get_workflow(result.value)) self.links[new_workflow_id].extend( ...
[ "def", "store_result_in_db", "(", "self", ",", "result", ",", "always_cache", "=", "True", ")", ":", "job", "=", "self", "[", "result", ".", "key", "]", "def", "extend_dependent_links", "(", ")", ":", "with", "self", ".", "lock", ":", "new_workflow_id", ...
Store a result in the database.
[ "Store", "a", "result", "in", "the", "database", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/prov/sqlite.py#L316-L388
train
NLeSC/noodles
noodles/prov/sqlite.py
JobDB.add_time_stamp
def add_time_stamp(self, db_id, name): """Add a timestamp to the database.""" with self.lock: self.cur.execute( 'insert into "timestamps" ("job", "what")' 'values (?, ?);', (db_id, name))
python
def add_time_stamp(self, db_id, name): """Add a timestamp to the database.""" with self.lock: self.cur.execute( 'insert into "timestamps" ("job", "what")' 'values (?, ?);', (db_id, name))
[ "def", "add_time_stamp", "(", "self", ",", "db_id", ",", "name", ")", ":", "with", "self", ".", "lock", ":", "self", ".", "cur", ".", "execute", "(", "'insert into \"timestamps\" (\"job\", \"what\")'", "'values (?, ?);'", ",", "(", "db_id", ",", "name", ")", ...
Add a timestamp to the database.
[ "Add", "a", "timestamp", "to", "the", "database", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/prov/sqlite.py#L390-L395
train
NLeSC/noodles
examples/static_sum.py
static_sum
def static_sum(values, limit_n=1000): """Example of static sum routine.""" if len(values) < limit_n: return sum(values) else: half = len(values) // 2 return add( static_sum(values[:half], limit_n), static_sum(values[half:], limit_n))
python
def static_sum(values, limit_n=1000): """Example of static sum routine.""" if len(values) < limit_n: return sum(values) else: half = len(values) // 2 return add( static_sum(values[:half], limit_n), static_sum(values[half:], limit_n))
[ "def", "static_sum", "(", "values", ",", "limit_n", "=", "1000", ")", ":", "if", "len", "(", "values", ")", "<", "limit_n", ":", "return", "sum", "(", "values", ")", "else", ":", "half", "=", "len", "(", "values", ")", "//", "2", "return", "add", ...
Example of static sum routine.
[ "Example", "of", "static", "sum", "routine", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/examples/static_sum.py#L7-L16
train
NLeSC/noodles
examples/static_sum.py
dynamic_sum
def dynamic_sum(values, limit_n=1000, acc=0, depth=4): """Example of dynamic sum.""" if len(values) < limit_n: return acc + sum(values) if depth > 0: half = len(values) // 2 return add( dynamic_sum(values[:half], limit_n, acc, depth=depth-1), dynamic_sum(valu...
python
def dynamic_sum(values, limit_n=1000, acc=0, depth=4): """Example of dynamic sum.""" if len(values) < limit_n: return acc + sum(values) if depth > 0: half = len(values) // 2 return add( dynamic_sum(values[:half], limit_n, acc, depth=depth-1), dynamic_sum(valu...
[ "def", "dynamic_sum", "(", "values", ",", "limit_n", "=", "1000", ",", "acc", "=", "0", ",", "depth", "=", "4", ")", ":", "if", "len", "(", "values", ")", "<", "limit_n", ":", "return", "acc", "+", "sum", "(", "values", ")", "if", "depth", ">", ...
Example of dynamic sum.
[ "Example", "of", "dynamic", "sum", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/examples/static_sum.py#L20-L32
train
NLeSC/noodles
noodles/lib/queue.py
Queue.flush
def flush(self): """Erases queue and set `end-of-queue` message.""" while not self._queue.empty(): self._queue.get() self._queue.task_done() self.close()
python
def flush(self): """Erases queue and set `end-of-queue` message.""" while not self._queue.empty(): self._queue.get() self._queue.task_done() self.close()
[ "def", "flush", "(", "self", ")", ":", "while", "not", "self", ".", "_queue", ".", "empty", "(", ")", ":", "self", ".", "_queue", ".", "get", "(", ")", "self", ".", "_queue", ".", "task_done", "(", ")", "self", ".", "close", "(", ")" ]
Erases queue and set `end-of-queue` message.
[ "Erases", "queue", "and", "set", "end", "-", "of", "-", "queue", "message", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/lib/queue.py#L71-L76
train
NLeSC/noodles
noodles/workflow/graphs.py
find_links_to
def find_links_to(links, node): """Find links to a node. :param links: forward links of a workflow :type links: Mapping[NodeId, Set[(NodeId, ArgumentType, [int|str]])] :param node: index to a node :type node: int :returns: dictionary of sources for each argument :r...
python
def find_links_to(links, node): """Find links to a node. :param links: forward links of a workflow :type links: Mapping[NodeId, Set[(NodeId, ArgumentType, [int|str]])] :param node: index to a node :type node: int :returns: dictionary of sources for each argument :r...
[ "def", "find_links_to", "(", "links", ",", "node", ")", ":", "return", "{", "address", ":", "src", "for", "src", ",", "(", "tgt", ",", "address", ")", "in", "_all_valid", "(", "links", ")", "if", "tgt", "==", "node", "}" ]
Find links to a node. :param links: forward links of a workflow :type links: Mapping[NodeId, Set[(NodeId, ArgumentType, [int|str]])] :param node: index to a node :type node: int :returns: dictionary of sources for each argument :rtype: Mapping[(ArgumentType, [int|str])...
[ "Find", "links", "to", "a", "node", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/workflow/graphs.py#L1-L18
train
NLeSC/noodles
noodles/workflow/graphs.py
_all_valid
def _all_valid(links): """Iterates over all links, forgetting emtpy registers.""" for k, v in links.items(): for i in v: yield k, i
python
def _all_valid(links): """Iterates over all links, forgetting emtpy registers.""" for k, v in links.items(): for i in v: yield k, i
[ "def", "_all_valid", "(", "links", ")", ":", "for", "k", ",", "v", "in", "links", ".", "items", "(", ")", ":", "for", "i", "in", "v", ":", "yield", "k", ",", "i" ]
Iterates over all links, forgetting emtpy registers.
[ "Iterates", "over", "all", "links", "forgetting", "emtpy", "registers", "." ]
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/workflow/graphs.py#L21-L25
train
NLeSC/noodles
noodles/workflow/create.py
from_call
def from_call(foo, args, kwargs, hints, call_by_value=True): """Takes a function and a set of arguments it needs to run on. Returns a newly constructed workflow representing the promised value from the evaluation of the function with said arguments. These arguments are stored in a BoundArguments object...
python
def from_call(foo, args, kwargs, hints, call_by_value=True): """Takes a function and a set of arguments it needs to run on. Returns a newly constructed workflow representing the promised value from the evaluation of the function with said arguments. These arguments are stored in a BoundArguments object...
[ "def", "from_call", "(", "foo", ",", "args", ",", "kwargs", ",", "hints", ",", "call_by_value", "=", "True", ")", ":", "bound_args", "=", "signature", "(", "foo", ")", ".", "bind", "(", "*", "args", ",", "**", "kwargs", ")", "bound_args", ".", "apply...
Takes a function and a set of arguments it needs to run on. Returns a newly constructed workflow representing the promised value from the evaluation of the function with said arguments. These arguments are stored in a BoundArguments object matching to the signature of the given function ``foo``. That i...
[ "Takes", "a", "function", "and", "a", "set", "of", "arguments", "it", "needs", "to", "run", "on", ".", "Returns", "a", "newly", "constructed", "workflow", "representing", "the", "promised", "value", "from", "the", "evaluation", "of", "the", "function", "with...
3759e24e6e54a3a1a364431309dbb1061f617c04
https://github.com/NLeSC/noodles/blob/3759e24e6e54a3a1a364431309dbb1061f617c04/noodles/workflow/create.py#L10-L119
train