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
Kronuz/pyScss
scss/extension/compass/images.py
image_height
def image_height(image): """ Returns the height of the image found at the path supplied by `image` relative to your project's images directory. """ image_size_cache = _get_cache('image_size_cache') if not Image: raise SassMissingDependency('PIL', 'image manipulation') filepath = Stri...
python
def image_height(image): """ Returns the height of the image found at the path supplied by `image` relative to your project's images directory. """ image_size_cache = _get_cache('image_size_cache') if not Image: raise SassMissingDependency('PIL', 'image manipulation') filepath = Stri...
[ "def", "image_height", "(", "image", ")", ":", "image_size_cache", "=", "_get_cache", "(", "'image_size_cache'", ")", "if", "not", "Image", ":", "raise", "SassMissingDependency", "(", "'PIL'", ",", "'image manipulation'", ")", "filepath", "=", "String", ".", "un...
Returns the height of the image found at the path supplied by `image` relative to your project's images directory.
[ "Returns", "the", "height", "of", "the", "image", "found", "at", "the", "path", "supplied", "by", "image", "relative", "to", "your", "project", "s", "images", "directory", "." ]
fb32b317f6e2b4b4aad2b86a74844658ac4aa11e
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/extension/compass/images.py#L258-L289
train
Kronuz/pyScss
scss/source.py
SourceFile.path
def path(self): """Concatenation of ``origin`` and ``relpath``, as a string. Used in stack traces and other debugging places. """ if self.origin: return six.text_type(self.origin / self.relpath) else: return six.text_type(self.relpath)
python
def path(self): """Concatenation of ``origin`` and ``relpath``, as a string. Used in stack traces and other debugging places. """ if self.origin: return six.text_type(self.origin / self.relpath) else: return six.text_type(self.relpath)
[ "def", "path", "(", "self", ")", ":", "if", "self", ".", "origin", ":", "return", "six", ".", "text_type", "(", "self", ".", "origin", "/", "self", ".", "relpath", ")", "else", ":", "return", "six", ".", "text_type", "(", "self", ".", "relpath", ")...
Concatenation of ``origin`` and ``relpath``, as a string. Used in stack traces and other debugging places.
[ "Concatenation", "of", "origin", "and", "relpath", "as", "a", "string", ".", "Used", "in", "stack", "traces", "and", "other", "debugging", "places", "." ]
fb32b317f6e2b4b4aad2b86a74844658ac4aa11e
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/source.py#L125-L132
train
Kronuz/pyScss
scss/source.py
SourceFile.from_filename
def from_filename(cls, path_string, origin=MISSING, **kwargs): """ Read Sass source from a String specifying the path """ path = Path(path_string) return cls.from_path(path, origin, **kwargs)
python
def from_filename(cls, path_string, origin=MISSING, **kwargs): """ Read Sass source from a String specifying the path """ path = Path(path_string) return cls.from_path(path, origin, **kwargs)
[ "def", "from_filename", "(", "cls", ",", "path_string", ",", "origin", "=", "MISSING", ",", "*", "*", "kwargs", ")", ":", "path", "=", "Path", "(", "path_string", ")", "return", "cls", ".", "from_path", "(", "path", ",", "origin", ",", "*", "*", "kwa...
Read Sass source from a String specifying the path
[ "Read", "Sass", "source", "from", "a", "String", "specifying", "the", "path" ]
fb32b317f6e2b4b4aad2b86a74844658ac4aa11e
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/source.py#L194-L198
train
Kronuz/pyScss
scss/source.py
SourceFile.from_file
def from_file(cls, f, origin=MISSING, relpath=MISSING, **kwargs): """Read Sass source from a file or file-like object. If `origin` or `relpath` are missing, they are derived from the file's ``.name`` attribute as with `from_path`. If it doesn't have one, the origin becomes None and the...
python
def from_file(cls, f, origin=MISSING, relpath=MISSING, **kwargs): """Read Sass source from a file or file-like object. If `origin` or `relpath` are missing, they are derived from the file's ``.name`` attribute as with `from_path`. If it doesn't have one, the origin becomes None and the...
[ "def", "from_file", "(", "cls", ",", "f", ",", "origin", "=", "MISSING", ",", "relpath", "=", "MISSING", ",", "*", "*", "kwargs", ")", ":", "contents", "=", "f", ".", "read", "(", ")", "encoding", "=", "determine_encoding", "(", "contents", ")", "if"...
Read Sass source from a file or file-like object. If `origin` or `relpath` are missing, they are derived from the file's ``.name`` attribute as with `from_path`. If it doesn't have one, the origin becomes None and the relpath becomes the file's repr.
[ "Read", "Sass", "source", "from", "a", "file", "or", "file", "-", "like", "object", "." ]
fb32b317f6e2b4b4aad2b86a74844658ac4aa11e
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/source.py#L201-L221
train
Kronuz/pyScss
scss/source.py
SourceFile.from_string
def from_string(cls, string, relpath=None, encoding=None, is_sass=None): """Read Sass source from the contents of a string. The origin is always None. `relpath` defaults to "string:...". """ if isinstance(string, six.text_type): # Already decoded; we don't know what encodin...
python
def from_string(cls, string, relpath=None, encoding=None, is_sass=None): """Read Sass source from the contents of a string. The origin is always None. `relpath` defaults to "string:...". """ if isinstance(string, six.text_type): # Already decoded; we don't know what encodin...
[ "def", "from_string", "(", "cls", ",", "string", ",", "relpath", "=", "None", ",", "encoding", "=", "None", ",", "is_sass", "=", "None", ")", ":", "if", "isinstance", "(", "string", ",", "six", ".", "text_type", ")", ":", "# Already decoded; we don't know ...
Read Sass source from the contents of a string. The origin is always None. `relpath` defaults to "string:...".
[ "Read", "Sass", "source", "from", "the", "contents", "of", "a", "string", "." ]
fb32b317f6e2b4b4aad2b86a74844658ac4aa11e
https://github.com/Kronuz/pyScss/blob/fb32b317f6e2b4b4aad2b86a74844658ac4aa11e/scss/source.py#L224-L256
train
bitcraft/pyscroll
pyscroll/quadtree.py
FastQuadTree.hit
def hit(self, rect): """Returns the items that overlap a bounding rectangle. Returns the set of all items in the quad-tree that overlap with a bounding rectangle. @param rect: The bounding rectangle being tested against the quad-tree. This must possess left, top...
python
def hit(self, rect): """Returns the items that overlap a bounding rectangle. Returns the set of all items in the quad-tree that overlap with a bounding rectangle. @param rect: The bounding rectangle being tested against the quad-tree. This must possess left, top...
[ "def", "hit", "(", "self", ",", "rect", ")", ":", "# Find the hits at the current level.", "hits", "=", "{", "tuple", "(", "self", ".", "items", "[", "i", "]", ")", "for", "i", "in", "rect", ".", "collidelistall", "(", "self", ".", "items", ")", "}", ...
Returns the items that overlap a bounding rectangle. Returns the set of all items in the quad-tree that overlap with a bounding rectangle. @param rect: The bounding rectangle being tested against the quad-tree. This must possess left, top, right and bottom attributes.
[ "Returns", "the", "items", "that", "overlap", "a", "bounding", "rectangle", "." ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/quadtree.py#L105-L129
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.scroll
def scroll(self, vector): """ scroll the background in pixels :param vector: (int, int) """ self.center((vector[0] + self.view_rect.centerx, vector[1] + self.view_rect.centery))
python
def scroll(self, vector): """ scroll the background in pixels :param vector: (int, int) """ self.center((vector[0] + self.view_rect.centerx, vector[1] + self.view_rect.centery))
[ "def", "scroll", "(", "self", ",", "vector", ")", ":", "self", ".", "center", "(", "(", "vector", "[", "0", "]", "+", "self", ".", "view_rect", ".", "centerx", ",", "vector", "[", "1", "]", "+", "self", ".", "view_rect", ".", "centery", ")", ")" ...
scroll the background in pixels :param vector: (int, int)
[ "scroll", "the", "background", "in", "pixels" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L87-L93
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.center
def center(self, coords): """ center the map on a pixel float numbers will be rounded. :param coords: (number, number) """ x, y = round(coords[0]), round(coords[1]) self.view_rect.center = x, y mw, mh = self.data.map_size tw, th = self.data.tile_size ...
python
def center(self, coords): """ center the map on a pixel float numbers will be rounded. :param coords: (number, number) """ x, y = round(coords[0]), round(coords[1]) self.view_rect.center = x, y mw, mh = self.data.map_size tw, th = self.data.tile_size ...
[ "def", "center", "(", "self", ",", "coords", ")", ":", "x", ",", "y", "=", "round", "(", "coords", "[", "0", "]", ")", ",", "round", "(", "coords", "[", "1", "]", ")", "self", ".", "view_rect", ".", "center", "=", "x", ",", "y", "mw", ",", ...
center the map on a pixel float numbers will be rounded. :param coords: (number, number)
[ "center", "the", "map", "on", "a", "pixel" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L95-L163
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.draw
def draw(self, surface, rect, surfaces=None): """ Draw the map onto a surface pass a rect that defines the draw area for: drawing to an area smaller that the whole window/screen surfaces may optionally be passed that will be blitted onto the surface. this must be a sequence...
python
def draw(self, surface, rect, surfaces=None): """ Draw the map onto a surface pass a rect that defines the draw area for: drawing to an area smaller that the whole window/screen surfaces may optionally be passed that will be blitted onto the surface. this must be a sequence...
[ "def", "draw", "(", "self", ",", "surface", ",", "rect", ",", "surfaces", "=", "None", ")", ":", "if", "self", ".", "_zoom_level", "==", "1.0", ":", "self", ".", "_render_map", "(", "surface", ",", "rect", ",", "surfaces", ")", "else", ":", "self", ...
Draw the map onto a surface pass a rect that defines the draw area for: drawing to an area smaller that the whole window/screen surfaces may optionally be passed that will be blitted onto the surface. this must be a sequence of tuples containing a layer number, image, and r...
[ "Draw", "the", "map", "onto", "a", "surface" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L165-L193
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.set_size
def set_size(self, size): """ Set the size of the map in pixels This is an expensive operation, do only when absolutely needed. :param size: (width, height) pixel size of camera/view of the group """ buffer_size = self._calculate_zoom_buffer_size(size, self._zoom_level) ...
python
def set_size(self, size): """ Set the size of the map in pixels This is an expensive operation, do only when absolutely needed. :param size: (width, height) pixel size of camera/view of the group """ buffer_size = self._calculate_zoom_buffer_size(size, self._zoom_level) ...
[ "def", "set_size", "(", "self", ",", "size", ")", ":", "buffer_size", "=", "self", ".", "_calculate_zoom_buffer_size", "(", "size", ",", "self", ".", "_zoom_level", ")", "self", ".", "_size", "=", "size", "self", ".", "_initialize_buffers", "(", "buffer_size...
Set the size of the map in pixels This is an expensive operation, do only when absolutely needed. :param size: (width, height) pixel size of camera/view of the group
[ "Set", "the", "size", "of", "the", "map", "in", "pixels" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L219-L228
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.translate_point
def translate_point(self, point): """ Translate world coordinates and return screen coordinates. Respects zoom level Will be returned as tuple. :rtype: tuple """ mx, my = self.get_center_offset() if self._zoom_level == 1.0: return point[0] + mx, point[1] + ...
python
def translate_point(self, point): """ Translate world coordinates and return screen coordinates. Respects zoom level Will be returned as tuple. :rtype: tuple """ mx, my = self.get_center_offset() if self._zoom_level == 1.0: return point[0] + mx, point[1] + ...
[ "def", "translate_point", "(", "self", ",", "point", ")", ":", "mx", ",", "my", "=", "self", ".", "get_center_offset", "(", ")", "if", "self", ".", "_zoom_level", "==", "1.0", ":", "return", "point", "[", "0", "]", "+", "mx", ",", "point", "[", "1"...
Translate world coordinates and return screen coordinates. Respects zoom level Will be returned as tuple. :rtype: tuple
[ "Translate", "world", "coordinates", "and", "return", "screen", "coordinates", ".", "Respects", "zoom", "level" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L246-L257
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer.translate_points
def translate_points(self, points): """ Translate coordinates and return screen coordinates Will be returned in order passed as tuples. :return: list """ retval = list() append = retval.append sx, sy = self.get_center_offset() if self._zoom_level == 1.0:...
python
def translate_points(self, points): """ Translate coordinates and return screen coordinates Will be returned in order passed as tuples. :return: list """ retval = list() append = retval.append sx, sy = self.get_center_offset() if self._zoom_level == 1.0:...
[ "def", "translate_points", "(", "self", ",", "points", ")", ":", "retval", "=", "list", "(", ")", "append", "=", "retval", ".", "append", "sx", ",", "sy", "=", "self", ".", "get_center_offset", "(", ")", "if", "self", ".", "_zoom_level", "==", "1.0", ...
Translate coordinates and return screen coordinates Will be returned in order passed as tuples. :return: list
[ "Translate", "coordinates", "and", "return", "screen", "coordinates" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L273-L291
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._render_map
def _render_map(self, surface, rect, surfaces): """ Render the map and optional surfaces to destination surface :param surface: pygame surface to draw to :param rect: area to draw to :param surfaces: optional sequence of surfaces to interlace between tiles """ self._tile...
python
def _render_map(self, surface, rect, surfaces): """ Render the map and optional surfaces to destination surface :param surface: pygame surface to draw to :param rect: area to draw to :param surfaces: optional sequence of surfaces to interlace between tiles """ self._tile...
[ "def", "_render_map", "(", "self", ",", "surface", ",", "rect", ",", "surfaces", ")", ":", "self", ".", "_tile_queue", "=", "self", ".", "data", ".", "process_animation_queue", "(", "self", ".", "_tile_view", ")", "self", ".", "_tile_queue", "and", "self",...
Render the map and optional surfaces to destination surface :param surface: pygame surface to draw to :param rect: area to draw to :param surfaces: optional sequence of surfaces to interlace between tiles
[ "Render", "the", "map", "and", "optional", "surfaces", "to", "destination", "surface" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L315-L337
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._clear_surface
def _clear_surface(self, surface, rect=None): """ Clear the buffer, taking in account colorkey or alpha :return: """ clear_color = self._rgb_clear_color if self._clear_color is None else self._clear_color surface.fill(clear_color, rect)
python
def _clear_surface(self, surface, rect=None): """ Clear the buffer, taking in account colorkey or alpha :return: """ clear_color = self._rgb_clear_color if self._clear_color is None else self._clear_color surface.fill(clear_color, rect)
[ "def", "_clear_surface", "(", "self", ",", "surface", ",", "rect", "=", "None", ")", ":", "clear_color", "=", "self", ".", "_rgb_clear_color", "if", "self", ".", "_clear_color", "is", "None", "else", "self", ".", "_clear_color", "surface", ".", "fill", "("...
Clear the buffer, taking in account colorkey or alpha :return:
[ "Clear", "the", "buffer", "taking", "in", "account", "colorkey", "or", "alpha" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L339-L345
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._draw_surfaces
def _draw_surfaces(self, surface, offset, surfaces): """ Draw surfaces onto buffer, then redraw tiles that cover them :param surface: destination :param offset: offset to compensate for buffer alignment :param surfaces: sequence of surfaces to blit """ surface_blit = sur...
python
def _draw_surfaces(self, surface, offset, surfaces): """ Draw surfaces onto buffer, then redraw tiles that cover them :param surface: destination :param offset: offset to compensate for buffer alignment :param surfaces: sequence of surfaces to blit """ surface_blit = sur...
[ "def", "_draw_surfaces", "(", "self", ",", "surface", ",", "offset", ",", "surfaces", ")", ":", "surface_blit", "=", "surface", ".", "blit", "ox", ",", "oy", "=", "offset", "left", ",", "top", "=", "self", ".", "_tile_view", ".", "topleft", "hit", "=",...
Draw surfaces onto buffer, then redraw tiles that cover them :param surface: destination :param offset: offset to compensate for buffer alignment :param surfaces: sequence of surfaces to blit
[ "Draw", "surfaces", "onto", "buffer", "then", "redraw", "tiles", "that", "cover", "them" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L347-L394
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._queue_edge_tiles
def _queue_edge_tiles(self, dx, dy): """ Queue edge tiles and clear edge areas on buffer if needed :param dx: Edge along X axis to enqueue :param dy: Edge along Y axis to enqueue :return: None """ v = self._tile_view tw, th = self.data.tile_size self._til...
python
def _queue_edge_tiles(self, dx, dy): """ Queue edge tiles and clear edge areas on buffer if needed :param dx: Edge along X axis to enqueue :param dy: Edge along Y axis to enqueue :return: None """ v = self._tile_view tw, th = self.data.tile_size self._til...
[ "def", "_queue_edge_tiles", "(", "self", ",", "dx", ",", "dy", ")", ":", "v", "=", "self", ".", "_tile_view", "tw", ",", "th", "=", "self", ".", "data", ".", "tile_size", "self", ".", "_tile_queue", "=", "iter", "(", "[", "]", ")", "def", "append",...
Queue edge tiles and clear edge areas on buffer if needed :param dx: Edge along X axis to enqueue :param dy: Edge along Y axis to enqueue :return: None
[ "Queue", "edge", "tiles", "and", "clear", "edge", "areas", "on", "buffer", "if", "needed" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L396-L423
train
bitcraft/pyscroll
pyscroll/orthographic.py
BufferedRenderer._create_buffers
def _create_buffers(self, view_size, buffer_size): """ Create the buffers, taking in account pixel alpha or colorkey :param view_size: pixel size of the view :param buffer_size: pixel size of the buffer """ requires_zoom_buffer = not view_size == buffer_size self._zoom_b...
python
def _create_buffers(self, view_size, buffer_size): """ Create the buffers, taking in account pixel alpha or colorkey :param view_size: pixel size of the view :param buffer_size: pixel size of the buffer """ requires_zoom_buffer = not view_size == buffer_size self._zoom_b...
[ "def", "_create_buffers", "(", "self", ",", "view_size", ",", "buffer_size", ")", ":", "requires_zoom_buffer", "=", "not", "view_size", "==", "buffer_size", "self", ".", "_zoom_buffer", "=", "None", "if", "self", ".", "_clear_color", "is", "None", ":", "if", ...
Create the buffers, taking in account pixel alpha or colorkey :param view_size: pixel size of the view :param buffer_size: pixel size of the buffer
[ "Create", "the", "buffers", "taking", "in", "account", "pixel", "alpha", "or", "colorkey" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/orthographic.py#L433-L457
train
bitcraft/pyscroll
pyscroll/data.py
PyscrollDataAdapter.reload_animations
def reload_animations(self): """ Reload animation information PyscrollDataAdapter.get_animations must be implemented """ self._update_time() self._animation_queue = list() self._tracked_gids = set() self._animation_map = dict() for gid, frame_data in se...
python
def reload_animations(self): """ Reload animation information PyscrollDataAdapter.get_animations must be implemented """ self._update_time() self._animation_queue = list() self._tracked_gids = set() self._animation_map = dict() for gid, frame_data in se...
[ "def", "reload_animations", "(", "self", ")", ":", "self", ".", "_update_time", "(", ")", "self", ".", "_animation_queue", "=", "list", "(", ")", "self", ".", "_tracked_gids", "=", "set", "(", ")", "self", ".", "_animation_map", "=", "dict", "(", ")", ...
Reload animation information PyscrollDataAdapter.get_animations must be implemented
[ "Reload", "animation", "information" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L132-L161
train
bitcraft/pyscroll
pyscroll/data.py
PyscrollDataAdapter.get_tile_image
def get_tile_image(self, x, y, l): """ Get a tile image, respecting current animations :param x: x coordinate :param y: y coordinate :param l: layer :type x: int :type y: int :type l: int :rtype: pygame.Surface """ # disabled for now, re...
python
def get_tile_image(self, x, y, l): """ Get a tile image, respecting current animations :param x: x coordinate :param y: y coordinate :param l: layer :type x: int :type y: int :type l: int :rtype: pygame.Surface """ # disabled for now, re...
[ "def", "get_tile_image", "(", "self", ",", "x", ",", "y", ",", "l", ")", ":", "# disabled for now, re-enable when support for generic maps is restored", "# # since the tile has been queried, assume it wants to be checked", "# # for animations sometime in the future", "# if self._animat...
Get a tile image, respecting current animations :param x: x coordinate :param y: y coordinate :param l: layer :type x: int :type y: int :type l: int :rtype: pygame.Surface
[ "Get", "a", "tile", "image", "respecting", "current", "animations" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L163-L189
train
bitcraft/pyscroll
pyscroll/data.py
PyscrollDataAdapter.get_tile_images_by_rect
def get_tile_images_by_rect(self, rect): """ Given a 2d area, return generator of tile images inside Given the coordinates, yield the following tuple for each tile: X, Y, Layer Number, pygame Surface This method also defines render order by re arranging the positions of each ...
python
def get_tile_images_by_rect(self, rect): """ Given a 2d area, return generator of tile images inside Given the coordinates, yield the following tuple for each tile: X, Y, Layer Number, pygame Surface This method also defines render order by re arranging the positions of each ...
[ "def", "get_tile_images_by_rect", "(", "self", ",", "rect", ")", ":", "x1", ",", "y1", ",", "x2", ",", "y2", "=", "rect_to_bb", "(", "rect", ")", "for", "layer", "in", "self", ".", "visible_tile_layers", ":", "for", "y", ",", "x", "in", "product", "(...
Given a 2d area, return generator of tile images inside Given the coordinates, yield the following tuple for each tile: X, Y, Layer Number, pygame Surface This method also defines render order by re arranging the positions of each tile as it is yielded to the renderer. There...
[ "Given", "a", "2d", "area", "return", "generator", "of", "tile", "images", "inside" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L251-L277
train
bitcraft/pyscroll
pyscroll/data.py
TiledMapData.convert_surfaces
def convert_surfaces(self, parent, alpha=False): """ Convert all images in the data to match the parent :param parent: pygame.Surface :param alpha: preserve alpha channel or not :return: None """ images = list() for i in self.tmx.images: try: ...
python
def convert_surfaces(self, parent, alpha=False): """ Convert all images in the data to match the parent :param parent: pygame.Surface :param alpha: preserve alpha channel or not :return: None """ images = list() for i in self.tmx.images: try: ...
[ "def", "convert_surfaces", "(", "self", ",", "parent", ",", "alpha", "=", "False", ")", ":", "images", "=", "list", "(", ")", "for", "i", "in", "self", ".", "tmx", ".", "images", ":", "try", ":", "if", "alpha", ":", "images", ".", "append", "(", ...
Convert all images in the data to match the parent :param parent: pygame.Surface :param alpha: preserve alpha channel or not :return: None
[ "Convert", "all", "images", "in", "the", "data", "to", "match", "the", "parent" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L301-L317
train
bitcraft/pyscroll
pyscroll/data.py
TiledMapData.visible_object_layers
def visible_object_layers(self): """ This must return layer objects This is not required for custom data formats. :return: Sequence of pytmx object layers/groups """ return (layer for layer in self.tmx.visible_layers if isinstance(layer, pytmx.TiledObjectGroup))
python
def visible_object_layers(self): """ This must return layer objects This is not required for custom data formats. :return: Sequence of pytmx object layers/groups """ return (layer for layer in self.tmx.visible_layers if isinstance(layer, pytmx.TiledObjectGroup))
[ "def", "visible_object_layers", "(", "self", ")", ":", "return", "(", "layer", "for", "layer", "in", "self", ".", "tmx", ".", "visible_layers", "if", "isinstance", "(", "layer", ",", "pytmx", ".", "TiledObjectGroup", ")", ")" ]
This must return layer objects This is not required for custom data formats. :return: Sequence of pytmx object layers/groups
[ "This", "must", "return", "layer", "objects" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L344-L352
train
bitcraft/pyscroll
pyscroll/data.py
TiledMapData.get_tile_images_by_rect
def get_tile_images_by_rect(self, rect): """ Speed up data access More efficient because data is accessed and cached locally """ def rev(seq, start, stop): if start < 0: start = 0 return enumerate(seq[start:stop + 1], start) x1, y1, x2, ...
python
def get_tile_images_by_rect(self, rect): """ Speed up data access More efficient because data is accessed and cached locally """ def rev(seq, start, stop): if start < 0: start = 0 return enumerate(seq[start:stop + 1], start) x1, y1, x2, ...
[ "def", "get_tile_images_by_rect", "(", "self", ",", "rect", ")", ":", "def", "rev", "(", "seq", ",", "start", ",", "stop", ")", ":", "if", "start", "<", "0", ":", "start", "=", "0", "return", "enumerate", "(", "seq", "[", "start", ":", "stop", "+",...
Speed up data access More efficient because data is accessed and cached locally
[ "Speed", "up", "data", "access" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/data.py#L370-L404
train
bitcraft/pyscroll
tutorial/quest.py
Hero.move_back
def move_back(self, dt): """ If called after an update, the sprite can move back """ self._position = self._old_position self.rect.topleft = self._position self.feet.midbottom = self.rect.midbottom
python
def move_back(self, dt): """ If called after an update, the sprite can move back """ self._position = self._old_position self.rect.topleft = self._position self.feet.midbottom = self.rect.midbottom
[ "def", "move_back", "(", "self", ",", "dt", ")", ":", "self", ".", "_position", "=", "self", ".", "_old_position", "self", ".", "rect", ".", "topleft", "=", "self", ".", "_position", "self", ".", "feet", ".", "midbottom", "=", "self", ".", "rect", "....
If called after an update, the sprite can move back
[ "If", "called", "after", "an", "update", "the", "sprite", "can", "move", "back" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/tutorial/quest.py#L86-L91
train
bitcraft/pyscroll
tutorial/quest.py
QuestGame.handle_input
def handle_input(self): """ Handle pygame input events """ poll = pygame.event.poll event = poll() while event: if event.type == QUIT: self.running = False break elif event.type == KEYDOWN: if event.key == ...
python
def handle_input(self): """ Handle pygame input events """ poll = pygame.event.poll event = poll() while event: if event.type == QUIT: self.running = False break elif event.type == KEYDOWN: if event.key == ...
[ "def", "handle_input", "(", "self", ")", ":", "poll", "=", "pygame", ".", "event", ".", "poll", "event", "=", "poll", "(", ")", "while", "event", ":", "if", "event", ".", "type", "==", "QUIT", ":", "self", ".", "running", "=", "False", "break", "el...
Handle pygame input events
[ "Handle", "pygame", "input", "events" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/tutorial/quest.py#L149-L195
train
bitcraft/pyscroll
tutorial/quest.py
QuestGame.update
def update(self, dt): """ Tasks that occur over time should be handled here """ self.group.update(dt) # check if the sprite's feet are colliding with wall # sprite must have a rect called feet, and move_back method, # otherwise this will fail for sprite in self.g...
python
def update(self, dt): """ Tasks that occur over time should be handled here """ self.group.update(dt) # check if the sprite's feet are colliding with wall # sprite must have a rect called feet, and move_back method, # otherwise this will fail for sprite in self.g...
[ "def", "update", "(", "self", ",", "dt", ")", ":", "self", ".", "group", ".", "update", "(", "dt", ")", "# check if the sprite's feet are colliding with wall", "# sprite must have a rect called feet, and move_back method,", "# otherwise this will fail", "for", "sprite", "in...
Tasks that occur over time should be handled here
[ "Tasks", "that", "occur", "over", "time", "should", "be", "handled", "here" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/tutorial/quest.py#L197-L207
train
bitcraft/pyscroll
tutorial/quest.py
QuestGame.run
def run(self): """ Run the game loop """ clock = pygame.time.Clock() self.running = True from collections import deque times = deque(maxlen=30) try: while self.running: dt = clock.tick() / 1000. times.append(clock.get_...
python
def run(self): """ Run the game loop """ clock = pygame.time.Clock() self.running = True from collections import deque times = deque(maxlen=30) try: while self.running: dt = clock.tick() / 1000. times.append(clock.get_...
[ "def", "run", "(", "self", ")", ":", "clock", "=", "pygame", ".", "time", ".", "Clock", "(", ")", "self", ".", "running", "=", "True", "from", "collections", "import", "deque", "times", "=", "deque", "(", "maxlen", "=", "30", ")", "try", ":", "whil...
Run the game loop
[ "Run", "the", "game", "loop" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/tutorial/quest.py#L209-L230
train
bitcraft/pyscroll
pyscroll/group.py
PyscrollGroup.draw
def draw(self, surface): """ Draw all sprites and map onto the surface :param surface: pygame surface to draw to :type surface: pygame.surface.Surface """ ox, oy = self._map_layer.get_center_offset() new_surfaces = list() spritedict = self.spritedict gl ...
python
def draw(self, surface): """ Draw all sprites and map onto the surface :param surface: pygame surface to draw to :type surface: pygame.surface.Surface """ ox, oy = self._map_layer.get_center_offset() new_surfaces = list() spritedict = self.spritedict gl ...
[ "def", "draw", "(", "self", ",", "surface", ")", ":", "ox", ",", "oy", "=", "self", ".", "_map_layer", ".", "get_center_offset", "(", ")", "new_surfaces", "=", "list", "(", ")", "spritedict", "=", "self", ".", "spritedict", "gl", "=", "self", ".", "g...
Draw all sprites and map onto the surface :param surface: pygame surface to draw to :type surface: pygame.surface.Surface
[ "Draw", "all", "sprites", "and", "map", "onto", "the", "surface" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/group.py#L34-L56
train
bitcraft/pyscroll
pyscroll/isometric.py
IsometricBufferedRenderer.center
def center(self, coords): """ center the map on a "map pixel" """ x, y = [round(i, 0) for i in coords] self.view_rect.center = x, y tw, th = self.data.tile_size left, ox = divmod(x, tw) top, oy = divmod(y, th) vec = int(ox / 2), int(oy) iso = v...
python
def center(self, coords): """ center the map on a "map pixel" """ x, y = [round(i, 0) for i in coords] self.view_rect.center = x, y tw, th = self.data.tile_size left, ox = divmod(x, tw) top, oy = divmod(y, th) vec = int(ox / 2), int(oy) iso = v...
[ "def", "center", "(", "self", ",", "coords", ")", ":", "x", ",", "y", "=", "[", "round", "(", "i", ",", "0", ")", "for", "i", "in", "coords", "]", "self", ".", "view_rect", ".", "center", "=", "x", ",", "y", "tw", ",", "th", "=", "self", "....
center the map on a "map pixel"
[ "center", "the", "map", "on", "a", "map", "pixel" ]
b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f
https://github.com/bitcraft/pyscroll/blob/b41c1016dfefd0e2d83a14a2ce40d7ad298c5b0f/pyscroll/isometric.py#L86-L127
train
acsone/click-odoo
click_odoo/env_options.py
env_options.get_odoo_args
def get_odoo_args(self, ctx): """Return a list of Odoo command line arguments from the Click context.""" config = ctx.params.get("config") addons_path = ctx.params.get("addons_path") database = ctx.params.get("database") log_level = ctx.params.get("log_level") logfile = c...
python
def get_odoo_args(self, ctx): """Return a list of Odoo command line arguments from the Click context.""" config = ctx.params.get("config") addons_path = ctx.params.get("addons_path") database = ctx.params.get("database") log_level = ctx.params.get("log_level") logfile = c...
[ "def", "get_odoo_args", "(", "self", ",", "ctx", ")", ":", "config", "=", "ctx", ".", "params", ".", "get", "(", "\"config\"", ")", "addons_path", "=", "ctx", ".", "params", ".", "get", "(", "\"addons_path\"", ")", "database", "=", "ctx", ".", "params"...
Return a list of Odoo command line arguments from the Click context.
[ "Return", "a", "list", "of", "Odoo", "command", "line", "arguments", "from", "the", "Click", "context", "." ]
7335f722bb6edbaf34cee29e027a49f47e83e052
https://github.com/acsone/click-odoo/blob/7335f722bb6edbaf34cee29e027a49f47e83e052/click_odoo/env_options.py#L123-L144
train
williamgilpin/pypdb
pypdb/pypdb.py
make_query
def make_query(search_term, querytype='AdvancedKeywordQuery'): ''' Repackage strings into a search dictionary This function takes a list of search terms and specifications and repackages it as a dictionary object that can be used to conduct a search Parameters ---------- search_term : str ...
python
def make_query(search_term, querytype='AdvancedKeywordQuery'): ''' Repackage strings into a search dictionary This function takes a list of search terms and specifications and repackages it as a dictionary object that can be used to conduct a search Parameters ---------- search_term : str ...
[ "def", "make_query", "(", "search_term", ",", "querytype", "=", "'AdvancedKeywordQuery'", ")", ":", "assert", "querytype", "in", "{", "'HoldingsQuery'", ",", "'ExpTypeQuery'", ",", "'AdvancedKeywordQuery'", ",", "'StructureIdQuery'", ",", "'ModifiedStructuresQuery'", ",...
Repackage strings into a search dictionary This function takes a list of search terms and specifications and repackages it as a dictionary object that can be used to conduct a search Parameters ---------- search_term : str The specific term to search in the database. For specific query ty...
[ "Repackage", "strings", "into", "a", "search", "dictionary" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L51-L159
train
williamgilpin/pypdb
pypdb/pypdb.py
do_protsym_search
def do_protsym_search(point_group, min_rmsd=0.0, max_rmsd=7.0): '''Performs a protein symmetry search of the PDB This function can search the Protein Data Bank based on how closely entries match the user-specified symmetry group Parameters ---------- point_group : str The name of the ...
python
def do_protsym_search(point_group, min_rmsd=0.0, max_rmsd=7.0): '''Performs a protein symmetry search of the PDB This function can search the Protein Data Bank based on how closely entries match the user-specified symmetry group Parameters ---------- point_group : str The name of the ...
[ "def", "do_protsym_search", "(", "point_group", ",", "min_rmsd", "=", "0.0", ",", "max_rmsd", "=", "7.0", ")", ":", "query_params", "=", "dict", "(", ")", "query_params", "[", "'queryType'", "]", "=", "'PointGroupQuery'", "query_params", "[", "'rMSDComparator'",...
Performs a protein symmetry search of the PDB This function can search the Protein Data Bank based on how closely entries match the user-specified symmetry group Parameters ---------- point_group : str The name of the symmetry point group to search. This includes all the standard ...
[ "Performs", "a", "protein", "symmetry", "search", "of", "the", "PDB" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L222-L270
train
williamgilpin/pypdb
pypdb/pypdb.py
get_all
def get_all(): """Return a list of all PDB entries currently in the RCSB Protein Data Bank Returns ------- out : list of str A list of all of the PDB IDs currently in the RCSB PDB Examples -------- >>> print(get_all()[:10]) ['100D', '101D', '101M', '102D', '102L', '102M', '10...
python
def get_all(): """Return a list of all PDB entries currently in the RCSB Protein Data Bank Returns ------- out : list of str A list of all of the PDB IDs currently in the RCSB PDB Examples -------- >>> print(get_all()[:10]) ['100D', '101D', '101M', '102D', '102L', '102M', '10...
[ "def", "get_all", "(", ")", ":", "url", "=", "'http://www.rcsb.org/pdb/rest/getCurrent'", "req", "=", "urllib", ".", "request", ".", "Request", "(", "url", ")", "f", "=", "urllib", ".", "request", ".", "urlopen", "(", "req", ")", "result", "=", "f", ".",...
Return a list of all PDB entries currently in the RCSB Protein Data Bank Returns ------- out : list of str A list of all of the PDB IDs currently in the RCSB PDB Examples -------- >>> print(get_all()[:10]) ['100D', '101D', '101M', '102D', '102L', '102M', '103D', '103L', '103M', '...
[ "Return", "a", "list", "of", "all", "PDB", "entries", "currently", "in", "the", "RCSB", "Protein", "Data", "Bank" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L273-L305
train
williamgilpin/pypdb
pypdb/pypdb.py
get_info
def get_info(pdb_id, url_root='http://www.rcsb.org/pdb/rest/describeMol?structureId='): '''Look up all information about a given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest url_root : string The string root of the specific url f...
python
def get_info(pdb_id, url_root='http://www.rcsb.org/pdb/rest/describeMol?structureId='): '''Look up all information about a given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest url_root : string The string root of the specific url f...
[ "def", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/describeMol?structureId='", ")", ":", "url", "=", "url_root", "+", "pdb_id", "req", "=", "urllib", ".", "request", ".", "Request", "(", "url", ")", "f", "=", "urllib", ".", ...
Look up all information about a given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest url_root : string The string root of the specific url for the request type Returns ------- out : OrderedDict An ordered dictiona...
[ "Look", "up", "all", "information", "about", "a", "given", "PDB", "ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L313-L341
train
williamgilpin/pypdb
pypdb/pypdb.py
get_pdb_file
def get_pdb_file(pdb_id, filetype='pdb', compression=False): '''Get the full PDB file associated with a PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest filetype: string The file type. 'pdb' is the older file format, ...
python
def get_pdb_file(pdb_id, filetype='pdb', compression=False): '''Get the full PDB file associated with a PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest filetype: string The file type. 'pdb' is the older file format, ...
[ "def", "get_pdb_file", "(", "pdb_id", ",", "filetype", "=", "'pdb'", ",", "compression", "=", "False", ")", ":", "full_url", "=", "\"https://files.rcsb.org/download/\"", "full_url", "+=", "pdb_id", "if", "(", "filetype", "==", "'structfact'", ")", ":", "full_url...
Get the full PDB file associated with a PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest filetype: string The file type. 'pdb' is the older file format, 'cif' is the newer replacement. 'xml' an also be obtained an...
[ "Get", "the", "full", "PDB", "file", "associated", "with", "a", "PDB_ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L343-L406
train
williamgilpin/pypdb
pypdb/pypdb.py
get_all_info
def get_all_info(pdb_id): '''A wrapper for get_info that cleans up the output slighly Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing all the information stored in the entry ...
python
def get_all_info(pdb_id): '''A wrapper for get_info that cleans up the output slighly Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing all the information stored in the entry ...
[ "def", "get_all_info", "(", "pdb_id", ")", ":", "out", "=", "to_dict", "(", "get_info", "(", "pdb_id", ")", ")", "[", "'molDescription'", "]", "[", "'structureId'", "]", "out", "=", "remove_at_sign", "(", "out", ")", "return", "out" ]
A wrapper for get_info that cleans up the output slighly Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing all the information stored in the entry Examples -------- >>> al...
[ "A", "wrapper", "for", "get_info", "that", "cleans", "up", "the", "output", "slighly" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L409-L445
train
williamgilpin/pypdb
pypdb/pypdb.py
get_raw_blast
def get_raw_blast(pdb_id, output_form='HTML', chain_id='A'): '''Look up full BLAST page for a given PDB ID get_blast() uses this function internally Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string A single character ...
python
def get_raw_blast(pdb_id, output_form='HTML', chain_id='A'): '''Look up full BLAST page for a given PDB ID get_blast() uses this function internally Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string A single character ...
[ "def", "get_raw_blast", "(", "pdb_id", ",", "output_form", "=", "'HTML'", ",", "chain_id", "=", "'A'", ")", ":", "url_root", "=", "'http://www.rcsb.org/pdb/rest/getBlastPDB2?structureId='", "url", "=", "url_root", "+", "pdb_id", "+", "'&chainId='", "+", "chain_id", ...
Look up full BLAST page for a given PDB ID get_blast() uses this function internally Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string A single character designating the chain ID of interest output_form : string ...
[ "Look", "up", "full", "BLAST", "page", "for", "a", "given", "PDB", "ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L447-L481
train
williamgilpin/pypdb
pypdb/pypdb.py
parse_blast
def parse_blast(blast_string): '''Clean up HTML BLAST results This function requires BeautifulSoup and the re module It goes throught the complicated output returned by the BLAST search and provides a list of matches, as well as the raw text file showing the alignments for each of the matches. ...
python
def parse_blast(blast_string): '''Clean up HTML BLAST results This function requires BeautifulSoup and the re module It goes throught the complicated output returned by the BLAST search and provides a list of matches, as well as the raw text file showing the alignments for each of the matches. ...
[ "def", "parse_blast", "(", "blast_string", ")", ":", "soup", "=", "BeautifulSoup", "(", "str", "(", "blast_string", ")", ",", "\"html.parser\"", ")", "all_blasts", "=", "list", "(", ")", "all_blast_ids", "=", "list", "(", ")", "pattern", "=", "'></a>....:'",...
Clean up HTML BLAST results This function requires BeautifulSoup and the re module It goes throught the complicated output returned by the BLAST search and provides a list of matches, as well as the raw text file showing the alignments for each of the matches. This function works best with HTML fo...
[ "Clean", "up", "HTML", "BLAST", "results" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L484-L528
train
williamgilpin/pypdb
pypdb/pypdb.py
get_blast2
def get_blast2(pdb_id, chain_id='A', output_form='HTML'): '''Alternative way to look up BLAST for a given PDB ID. This function is a wrapper for get_raw_blast and parse_blast Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string ...
python
def get_blast2(pdb_id, chain_id='A', output_form='HTML'): '''Alternative way to look up BLAST for a given PDB ID. This function is a wrapper for get_raw_blast and parse_blast Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string ...
[ "def", "get_blast2", "(", "pdb_id", ",", "chain_id", "=", "'A'", ",", "output_form", "=", "'HTML'", ")", ":", "raw_results", "=", "get_raw_blast", "(", "pdb_id", ",", "chain_id", "=", "chain_id", ",", "output_form", "=", "output_form", ")", "out", "=", "pa...
Alternative way to look up BLAST for a given PDB ID. This function is a wrapper for get_raw_blast and parse_blast Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest chain_id : string A single character designating the chain ID of interest ...
[ "Alternative", "way", "to", "look", "up", "BLAST", "for", "a", "given", "PDB", "ID", ".", "This", "function", "is", "a", "wrapper", "for", "get_raw_blast", "and", "parse_blast" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L531-L576
train
williamgilpin/pypdb
pypdb/pypdb.py
describe_pdb
def describe_pdb(pdb_id): """Get description and metadata of a PDB entry Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : string A text pdb description from PDB Examples -------- >>> describe_pdb(...
python
def describe_pdb(pdb_id): """Get description and metadata of a PDB entry Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : string A text pdb description from PDB Examples -------- >>> describe_pdb(...
[ "def", "describe_pdb", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/describePDB?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "out", "=", "remove_at_sign", "(", "out", "[", ...
Get description and metadata of a PDB entry Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : string A text pdb description from PDB Examples -------- >>> describe_pdb('4lza') {'citation_authors': ...
[ "Get", "description", "and", "metadata", "of", "a", "PDB", "entry" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L578-L615
train
williamgilpin/pypdb
pypdb/pypdb.py
get_entity_info
def get_entity_info(pdb_id): """Return pdb id information Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a description the entry Examples -------- >>> get_entity_inf...
python
def get_entity_info(pdb_id): """Return pdb id information Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a description the entry Examples -------- >>> get_entity_inf...
[ "def", "get_entity_info", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/getEntityInfo?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "return", "remove_at_sign", "(", "out", "[", ...
Return pdb id information Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a description the entry Examples -------- >>> get_entity_info('4lza') {'Entity': {'@id':...
[ "Return", "pdb", "id", "information" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L617-L647
train
williamgilpin/pypdb
pypdb/pypdb.py
get_ligands
def get_ligands(pdb_id): """Return ligands of given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a list of ligands associated with the entry Examples -------- ...
python
def get_ligands(pdb_id): """Return ligands of given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a list of ligands associated with the entry Examples -------- ...
[ "def", "get_ligands", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/ligandInfo?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "return", "remove_at_sign", "(", "out", "[", "'stru...
Return ligands of given PDB ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing a list of ligands associated with the entry Examples -------- >>> ligand_dict = get_ligand...
[ "Return", "ligands", "of", "given", "PDB", "ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L681-L715
train
williamgilpin/pypdb
pypdb/pypdb.py
get_gene_onto
def get_gene_onto(pdb_id): """Return ligands of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the gene ontology information associated with the entry Examples ...
python
def get_gene_onto(pdb_id): """Return ligands of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the gene ontology information associated with the entry Examples ...
[ "def", "get_gene_onto", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/goTerms?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "if", "not", "out", "[", "'goTerms'", "]", ":", ...
Return ligands of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the gene ontology information associated with the entry Examples -------- >>> gene_info = ...
[ "Return", "ligands", "of", "given", "PDB_ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L717-L755
train
williamgilpin/pypdb
pypdb/pypdb.py
get_seq_cluster
def get_seq_cluster(pdb_id_chain): """Get the sequence cluster of a PDB ID plus a pdb_id plus a chain, Parameters ---------- pdb_id_chain : string A string denoting a 4 character PDB ID plus a one character chain offset with a dot: XXXX.X, as in 2F5N.A Returns ------- out...
python
def get_seq_cluster(pdb_id_chain): """Get the sequence cluster of a PDB ID plus a pdb_id plus a chain, Parameters ---------- pdb_id_chain : string A string denoting a 4 character PDB ID plus a one character chain offset with a dot: XXXX.X, as in 2F5N.A Returns ------- out...
[ "def", "get_seq_cluster", "(", "pdb_id_chain", ")", ":", "url_root", "=", "'http://www.rcsb.org/pdb/rest/sequenceCluster?structureId='", "out", "=", "get_info", "(", "pdb_id_chain", ",", "url_root", "=", "url_root", ")", "out", "=", "to_dict", "(", "out", ")", "retu...
Get the sequence cluster of a PDB ID plus a pdb_id plus a chain, Parameters ---------- pdb_id_chain : string A string denoting a 4 character PDB ID plus a one character chain offset with a dot: XXXX.X, as in 2F5N.A Returns ------- out : dict A dictionary containing th...
[ "Get", "the", "sequence", "cluster", "of", "a", "PDB", "ID", "plus", "a", "pdb_id", "plus", "a", "chain" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L757-L795
train
williamgilpin/pypdb
pypdb/pypdb.py
get_pfam
def get_pfam(pdb_id): """Return PFAM annotations of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the PFAM annotations for the specified PDB ID Examples --...
python
def get_pfam(pdb_id): """Return PFAM annotations of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the PFAM annotations for the specified PDB ID Examples --...
[ "def", "get_pfam", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/hmmer?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "if", "not", "out", "[", "'hmmer3'", "]", ":", "return"...
Return PFAM annotations of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the PFAM annotations for the specified PDB ID Examples -------- >>> pfam_info = g...
[ "Return", "PFAM", "annotations", "of", "given", "PDB_ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L844-L873
train
williamgilpin/pypdb
pypdb/pypdb.py
get_clusters
def get_clusters(pdb_id): """Return cluster related web services of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the representative clusters for the specified PDB ...
python
def get_clusters(pdb_id): """Return cluster related web services of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the representative clusters for the specified PDB ...
[ "def", "get_clusters", "(", "pdb_id", ")", ":", "out", "=", "get_info", "(", "pdb_id", ",", "url_root", "=", "'http://www.rcsb.org/pdb/rest/representatives?structureId='", ")", "out", "=", "to_dict", "(", "out", ")", "return", "remove_at_sign", "(", "out", "[", ...
Return cluster related web services of given PDB_ID Parameters ---------- pdb_id : string A 4 character string giving a pdb entry of interest Returns ------- out : dict A dictionary containing the representative clusters for the specified PDB ID Examples -------- ...
[ "Return", "cluster", "related", "web", "services", "of", "given", "PDB_ID" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L875-L900
train
williamgilpin/pypdb
pypdb/pypdb.py
find_results_gen
def find_results_gen(search_term, field='title'): ''' Return a generator of the results returned by a search of the protein data bank. This generator is used internally. Parameters ---------- search_term : str The search keyword field : str The type of information to recor...
python
def find_results_gen(search_term, field='title'): ''' Return a generator of the results returned by a search of the protein data bank. This generator is used internally. Parameters ---------- search_term : str The search keyword field : str The type of information to recor...
[ "def", "find_results_gen", "(", "search_term", ",", "field", "=", "'title'", ")", ":", "scan_params", "=", "make_query", "(", "search_term", ",", "querytype", "=", "'AdvancedKeywordQuery'", ")", "search_result_ids", "=", "do_search", "(", "scan_params", ")", "all_...
Return a generator of the results returned by a search of the protein data bank. This generator is used internally. Parameters ---------- search_term : str The search keyword field : str The type of information to record about each entry Examples -------- >>> result_...
[ "Return", "a", "generator", "of", "the", "results", "returned", "by", "a", "search", "of", "the", "protein", "data", "bank", ".", "This", "generator", "is", "used", "internally", "." ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L904-L938
train
williamgilpin/pypdb
pypdb/pypdb.py
parse_results_gen
def parse_results_gen(search_term, field='title', max_results = 100, sleep_time=.1): ''' Query the PDB with a search term and field while respecting the query frequency limitations of the API. Parameters ---------- search_term : str The search keyword field : str The type...
python
def parse_results_gen(search_term, field='title', max_results = 100, sleep_time=.1): ''' Query the PDB with a search term and field while respecting the query frequency limitations of the API. Parameters ---------- search_term : str The search keyword field : str The type...
[ "def", "parse_results_gen", "(", "search_term", ",", "field", "=", "'title'", ",", "max_results", "=", "100", ",", "sleep_time", "=", ".1", ")", ":", "if", "max_results", "*", "sleep_time", ">", "30", ":", "warnings", ".", "warn", "(", "\"Because of API limi...
Query the PDB with a search term and field while respecting the query frequency limitations of the API. Parameters ---------- search_term : str The search keyword field : str The type of information to record about each entry max_results : int The maximum number of r...
[ "Query", "the", "PDB", "with", "a", "search", "term", "and", "field", "while", "respecting", "the", "query", "frequency", "limitations", "of", "the", "API", "." ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L940-L982
train
williamgilpin/pypdb
pypdb/pypdb.py
find_papers
def find_papers(search_term, **kwargs): ''' Return an ordered list of the top papers returned by a keyword search of the RCSB PDB Parameters ---------- search_term : str The search keyword max_results : int The maximum number of results to return Returns ------- ...
python
def find_papers(search_term, **kwargs): ''' Return an ordered list of the top papers returned by a keyword search of the RCSB PDB Parameters ---------- search_term : str The search keyword max_results : int The maximum number of results to return Returns ------- ...
[ "def", "find_papers", "(", "search_term", ",", "*", "*", "kwargs", ")", ":", "all_papers", "=", "parse_results_gen", "(", "search_term", ",", "field", "=", "'title'", ",", "*", "*", "kwargs", ")", "return", "remove_dupes", "(", "all_papers", ")" ]
Return an ordered list of the top papers returned by a keyword search of the RCSB PDB Parameters ---------- search_term : str The search keyword max_results : int The maximum number of results to return Returns ------- all_papers : list of strings A descendin...
[ "Return", "an", "ordered", "list", "of", "the", "top", "papers", "returned", "by", "a", "keyword", "search", "of", "the", "RCSB", "PDB" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L985-L1017
train
williamgilpin/pypdb
pypdb/pypdb.py
find_authors
def find_authors(search_term, **kwargs): '''Return an ordered list of the top authors returned by a keyword search of the RCSB PDB This function is based on the number of unique PDB entries a given author has his or her name associated with, and not author order or the ranking of the entry in the k...
python
def find_authors(search_term, **kwargs): '''Return an ordered list of the top authors returned by a keyword search of the RCSB PDB This function is based on the number of unique PDB entries a given author has his or her name associated with, and not author order or the ranking of the entry in the k...
[ "def", "find_authors", "(", "search_term", ",", "*", "*", "kwargs", ")", ":", "all_individuals", "=", "parse_results_gen", "(", "search_term", ",", "field", "=", "'citation_authors'", ",", "*", "*", "kwargs", ")", "full_author_list", "=", "[", "]", "for", "i...
Return an ordered list of the top authors returned by a keyword search of the RCSB PDB This function is based on the number of unique PDB entries a given author has his or her name associated with, and not author order or the ranking of the entry in the keyword search results. So if an author tends to ...
[ "Return", "an", "ordered", "list", "of", "the", "top", "authors", "returned", "by", "a", "keyword", "search", "of", "the", "RCSB", "PDB" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L1019-L1065
train
williamgilpin/pypdb
pypdb/pypdb.py
list_taxa
def list_taxa(pdb_list, sleep_time=.1): '''Given a list of PDB IDs, look up their associated species This function digs through the search results returned by the get_all_info() function and returns any information on taxonomy included within the description. The PDB website description of each en...
python
def list_taxa(pdb_list, sleep_time=.1): '''Given a list of PDB IDs, look up their associated species This function digs through the search results returned by the get_all_info() function and returns any information on taxonomy included within the description. The PDB website description of each en...
[ "def", "list_taxa", "(", "pdb_list", ",", "sleep_time", "=", ".1", ")", ":", "if", "len", "(", "pdb_list", ")", "*", "sleep_time", ">", "30", ":", "warnings", ".", "warn", "(", "\"Because of API limitations, this function\\\n will take at least \"", "+", "s...
Given a list of PDB IDs, look up their associated species This function digs through the search results returned by the get_all_info() function and returns any information on taxonomy included within the description. The PDB website description of each entry includes the name of the species (and s...
[ "Given", "a", "list", "of", "PDB", "IDs", "look", "up", "their", "associated", "species" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L1095-L1162
train
williamgilpin/pypdb
pypdb/pypdb.py
list_types
def list_types(pdb_list, sleep_time=.1): '''Given a list of PDB IDs, look up their associated structure type Parameters ---------- pdb_list : list of str List of PDB IDs sleep_time : float Time (in seconds) to wait between requests. If this number is too small the...
python
def list_types(pdb_list, sleep_time=.1): '''Given a list of PDB IDs, look up their associated structure type Parameters ---------- pdb_list : list of str List of PDB IDs sleep_time : float Time (in seconds) to wait between requests. If this number is too small the...
[ "def", "list_types", "(", "pdb_list", ",", "sleep_time", "=", ".1", ")", ":", "if", "len", "(", "pdb_list", ")", "*", "sleep_time", ">", "30", ":", "warnings", ".", "warn", "(", "\"Because of API limitations, this function\\\n will take at least \"", "+", "...
Given a list of PDB IDs, look up their associated structure type Parameters ---------- pdb_list : list of str List of PDB IDs sleep_time : float Time (in seconds) to wait between requests. If this number is too small the API will stop working, but it appears to vary a...
[ "Given", "a", "list", "of", "PDB", "IDs", "look", "up", "their", "associated", "structure", "type" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L1164-L1212
train
williamgilpin/pypdb
pypdb/pypdb.py
remove_dupes
def remove_dupes(list_with_dupes): '''Remove duplicate entries from a list while preserving order This function uses Python's standard equivalence testing methods in order to determine if two elements of a list are identical. So if in the list [a,b,c] the condition a == b is True, then regardless of wh...
python
def remove_dupes(list_with_dupes): '''Remove duplicate entries from a list while preserving order This function uses Python's standard equivalence testing methods in order to determine if two elements of a list are identical. So if in the list [a,b,c] the condition a == b is True, then regardless of wh...
[ "def", "remove_dupes", "(", "list_with_dupes", ")", ":", "visited", "=", "set", "(", ")", "visited_add", "=", "visited", ".", "add", "out", "=", "[", "entry", "for", "entry", "in", "list_with_dupes", "if", "not", "(", "entry", "in", "visited", "or", "vis...
Remove duplicate entries from a list while preserving order This function uses Python's standard equivalence testing methods in order to determine if two elements of a list are identical. So if in the list [a,b,c] the condition a == b is True, then regardless of whether a and b are strings, ints, or ot...
[ "Remove", "duplicate", "entries", "from", "a", "list", "while", "preserving", "order" ]
bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15
https://github.com/williamgilpin/pypdb/blob/bfb9e1b15b4ad097c5add50c4c176ac6cb28ee15/pypdb/pypdb.py#L1268-L1298
train
ndrplz/google-drive-downloader
google_drive_downloader/google_drive_downloader.py
GoogleDriveDownloader.download_file_from_google_drive
def download_file_from_google_drive(file_id, dest_path, overwrite=False, unzip=False, showsize=False): """ Downloads a shared file from google drive into a given folder. Optionally unzips it. Parameters ---------- file_id: str the file identifier. ...
python
def download_file_from_google_drive(file_id, dest_path, overwrite=False, unzip=False, showsize=False): """ Downloads a shared file from google drive into a given folder. Optionally unzips it. Parameters ---------- file_id: str the file identifier. ...
[ "def", "download_file_from_google_drive", "(", "file_id", ",", "dest_path", ",", "overwrite", "=", "False", ",", "unzip", "=", "False", ",", "showsize", "=", "False", ")", ":", "destination_directory", "=", "dirname", "(", "dest_path", ")", "if", "not", "exist...
Downloads a shared file from google drive into a given folder. Optionally unzips it. Parameters ---------- file_id: str the file identifier. You can obtain it from the sharable link. dest_path: str the destination where to save the downloaded ...
[ "Downloads", "a", "shared", "file", "from", "google", "drive", "into", "a", "given", "folder", ".", "Optionally", "unzips", "it", "." ]
be1aba9e2e43b2375475f19d8214ca50a8621bd6
https://github.com/ndrplz/google-drive-downloader/blob/be1aba9e2e43b2375475f19d8214ca50a8621bd6/google_drive_downloader/google_drive_downloader.py#L20-L78
train
python-hyper/wsproto
example/synchronous_server.py
handle_connection
def handle_connection(stream): ''' Handle a connection. The server operates a request/response cycle, so it performs a synchronous loop: 1) Read data from network into wsproto 2) Get next wsproto event 3) Handle event 4) Send data from wsproto to network :param stream: a socket st...
python
def handle_connection(stream): ''' Handle a connection. The server operates a request/response cycle, so it performs a synchronous loop: 1) Read data from network into wsproto 2) Get next wsproto event 3) Handle event 4) Send data from wsproto to network :param stream: a socket st...
[ "def", "handle_connection", "(", "stream", ")", ":", "ws", "=", "WSConnection", "(", "ConnectionType", ".", "SERVER", ")", "# events is a generator that yields websocket event objects. Usually you", "# would say `for event in ws.events()`, but the synchronous nature of this", "# serv...
Handle a connection. The server operates a request/response cycle, so it performs a synchronous loop: 1) Read data from network into wsproto 2) Get next wsproto event 3) Handle event 4) Send data from wsproto to network :param stream: a socket stream
[ "Handle", "a", "connection", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/example/synchronous_server.py#L44-L106
train
python-hyper/wsproto
wsproto/connection.py
Connection.receive_data
def receive_data(self, data): # type: (bytes) -> None """ Pass some received data to the connection for handling. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`~wsproto.connection.Connection.events`. :param data: The d...
python
def receive_data(self, data): # type: (bytes) -> None """ Pass some received data to the connection for handling. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`~wsproto.connection.Connection.events`. :param data: The d...
[ "def", "receive_data", "(", "self", ",", "data", ")", ":", "# type: (bytes) -> None", "if", "data", "is", "None", ":", "# \"If _The WebSocket Connection is Closed_ and no Close control", "# frame was received by the endpoint (such as could occur if the", "# underlying transport conne...
Pass some received data to the connection for handling. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`~wsproto.connection.Connection.events`. :param data: The data received from the remote peer on the network. :type data: ``bytes``
[ "Pass", "some", "received", "data", "to", "the", "connection", "for", "handling", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/connection.py#L92-L116
train
python-hyper/wsproto
wsproto/connection.py
Connection.events
def events(self): # type: () -> Generator[Event, None, None] """ Return a generator that provides any events that have been generated by protocol activity. :returns: generator of :class:`Event <wsproto.events.Event>` subclasses """ while self._events: ...
python
def events(self): # type: () -> Generator[Event, None, None] """ Return a generator that provides any events that have been generated by protocol activity. :returns: generator of :class:`Event <wsproto.events.Event>` subclasses """ while self._events: ...
[ "def", "events", "(", "self", ")", ":", "# type: () -> Generator[Event, None, None]", "while", "self", ".", "_events", ":", "yield", "self", ".", "_events", ".", "popleft", "(", ")", "try", ":", "for", "frame", "in", "self", ".", "_proto", ".", "received_fra...
Return a generator that provides any events that have been generated by protocol activity. :returns: generator of :class:`Event <wsproto.events.Event>` subclasses
[ "Return", "a", "generator", "that", "provides", "any", "events", "that", "have", "been", "generated", "by", "protocol", "activity", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/connection.py#L118-L161
train
python-hyper/wsproto
wsproto/handshake.py
server_extensions_handshake
def server_extensions_handshake(requested, supported): # type: (List[str], List[Extension]) -> Optional[bytes] """Agree on the extensions to use returning an appropriate header value. This returns None if there are no agreed extensions """ accepts = {} for offer in requested: name = off...
python
def server_extensions_handshake(requested, supported): # type: (List[str], List[Extension]) -> Optional[bytes] """Agree on the extensions to use returning an appropriate header value. This returns None if there are no agreed extensions """ accepts = {} for offer in requested: name = off...
[ "def", "server_extensions_handshake", "(", "requested", ",", "supported", ")", ":", "# type: (List[str], List[Extension]) -> Optional[bytes]", "accepts", "=", "{", "}", "for", "offer", "in", "requested", ":", "name", "=", "offer", ".", "split", "(", "\";\"", ",", ...
Agree on the extensions to use returning an appropriate header value. This returns None if there are no agreed extensions
[ "Agree", "on", "the", "extensions", "to", "use", "returning", "an", "appropriate", "header", "value", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/handshake.py#L411-L442
train
python-hyper/wsproto
wsproto/handshake.py
H11Handshake.initiate_upgrade_connection
def initiate_upgrade_connection(self, headers, path): # type: (List[Tuple[bytes, bytes]], str) -> None """Initiate an upgrade connection. This should be used if the request has already be received and parsed. """ if self.client: raise LocalProtocolError( ...
python
def initiate_upgrade_connection(self, headers, path): # type: (List[Tuple[bytes, bytes]], str) -> None """Initiate an upgrade connection. This should be used if the request has already be received and parsed. """ if self.client: raise LocalProtocolError( ...
[ "def", "initiate_upgrade_connection", "(", "self", ",", "headers", ",", "path", ")", ":", "# type: (List[Tuple[bytes, bytes]], str) -> None", "if", "self", ".", "client", ":", "raise", "LocalProtocolError", "(", "\"Cannot initiate an upgrade connection when acting as the client...
Initiate an upgrade connection. This should be used if the request has already be received and parsed.
[ "Initiate", "an", "upgrade", "connection", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/handshake.py#L61-L75
train
python-hyper/wsproto
wsproto/handshake.py
H11Handshake.send
def send(self, event): # type(Event) -> bytes """Send an event to the remote. This will return the bytes to send based on the event or raise a LocalProtocolError if the event is not valid given the state. """ data = b"" if isinstance(event, Request): ...
python
def send(self, event): # type(Event) -> bytes """Send an event to the remote. This will return the bytes to send based on the event or raise a LocalProtocolError if the event is not valid given the state. """ data = b"" if isinstance(event, Request): ...
[ "def", "send", "(", "self", ",", "event", ")", ":", "# type(Event) -> bytes", "data", "=", "b\"\"", "if", "isinstance", "(", "event", ",", "Request", ")", ":", "data", "+=", "self", ".", "_initiate_connection", "(", "event", ")", "elif", "isinstance", "(",...
Send an event to the remote. This will return the bytes to send based on the event or raise a LocalProtocolError if the event is not valid given the state.
[ "Send", "an", "event", "to", "the", "remote", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/handshake.py#L77-L99
train
python-hyper/wsproto
wsproto/handshake.py
H11Handshake.receive_data
def receive_data(self, data): # type: (bytes) -> None """Receive data from the remote. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`events`. """ self._h11_connection.receive_data(data) while True: ...
python
def receive_data(self, data): # type: (bytes) -> None """Receive data from the remote. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`events`. """ self._h11_connection.receive_data(data) while True: ...
[ "def", "receive_data", "(", "self", ",", "data", ")", ":", "# type: (bytes) -> None", "self", ".", "_h11_connection", ".", "receive_data", "(", "data", ")", "while", "True", ":", "try", ":", "event", "=", "self", ".", "_h11_connection", ".", "next_event", "(...
Receive data from the remote. A list of events that the remote peer triggered by sending this data can be retrieved with :meth:`events`.
[ "Receive", "data", "from", "the", "remote", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/wsproto/handshake.py#L101-L155
train
python-hyper/wsproto
example/synchronous_client.py
net_send
def net_send(out_data, conn): ''' Write pending data from websocket to network. ''' print('Sending {} bytes'.format(len(out_data))) conn.send(out_data)
python
def net_send(out_data, conn): ''' Write pending data from websocket to network. ''' print('Sending {} bytes'.format(len(out_data))) conn.send(out_data)
[ "def", "net_send", "(", "out_data", ",", "conn", ")", ":", "print", "(", "'Sending {} bytes'", ".", "format", "(", "len", "(", "out_data", ")", ")", ")", "conn", ".", "send", "(", "out_data", ")" ]
Write pending data from websocket to network.
[ "Write", "pending", "data", "from", "websocket", "to", "network", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/example/synchronous_client.py#L106-L109
train
python-hyper/wsproto
example/synchronous_client.py
net_recv
def net_recv(ws, conn): ''' Read pending data from network into websocket. ''' in_data = conn.recv(RECEIVE_BYTES) if not in_data: # A receive of zero bytes indicates the TCP socket has been closed. We # need to pass None to wsproto to update its internal state. print('Received 0 byte...
python
def net_recv(ws, conn): ''' Read pending data from network into websocket. ''' in_data = conn.recv(RECEIVE_BYTES) if not in_data: # A receive of zero bytes indicates the TCP socket has been closed. We # need to pass None to wsproto to update its internal state. print('Received 0 byte...
[ "def", "net_recv", "(", "ws", ",", "conn", ")", ":", "in_data", "=", "conn", ".", "recv", "(", "RECEIVE_BYTES", ")", "if", "not", "in_data", ":", "# A receive of zero bytes indicates the TCP socket has been closed. We", "# need to pass None to wsproto to update its internal...
Read pending data from network into websocket.
[ "Read", "pending", "data", "from", "network", "into", "websocket", "." ]
a7abcc5a9f7ad126668afb0cc9932da08c87f40f
https://github.com/python-hyper/wsproto/blob/a7abcc5a9f7ad126668afb0cc9932da08c87f40f/example/synchronous_client.py#L112-L122
train
ffalcinelli/pydivert
pydivert/windivert.py
WinDivert.check_filter
def check_filter(filter, layer=Layer.NETWORK): """ Checks if the given packet filter string is valid with respect to the filter language. The remapped function is WinDivertHelperCheckFilter:: BOOL WinDivertHelperCheckFilter( __in const char *filter, ...
python
def check_filter(filter, layer=Layer.NETWORK): """ Checks if the given packet filter string is valid with respect to the filter language. The remapped function is WinDivertHelperCheckFilter:: BOOL WinDivertHelperCheckFilter( __in const char *filter, ...
[ "def", "check_filter", "(", "filter", ",", "layer", "=", "Layer", ".", "NETWORK", ")", ":", "res", ",", "pos", ",", "msg", "=", "False", ",", "c_uint", "(", ")", ",", "c_char_p", "(", ")", "try", ":", "res", "=", "windivert_dll", ".", "WinDivertHelpe...
Checks if the given packet filter string is valid with respect to the filter language. The remapped function is WinDivertHelperCheckFilter:: BOOL WinDivertHelperCheckFilter( __in const char *filter, __in WINDIVERT_LAYER layer, __out_opt const char **...
[ "Checks", "if", "the", "given", "packet", "filter", "string", "is", "valid", "with", "respect", "to", "the", "filter", "language", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert.py#L102-L124
train
ffalcinelli/pydivert
pydivert/windivert.py
WinDivert.recv
def recv(self, bufsize=DEFAULT_PACKET_BUFFER_SIZE): """ Receives a diverted packet that matched the filter. The remapped function is WinDivertRecv:: BOOL WinDivertRecv( __in HANDLE handle, __out PVOID pPacket, __in UINT packetLen, ...
python
def recv(self, bufsize=DEFAULT_PACKET_BUFFER_SIZE): """ Receives a diverted packet that matched the filter. The remapped function is WinDivertRecv:: BOOL WinDivertRecv( __in HANDLE handle, __out PVOID pPacket, __in UINT packetLen, ...
[ "def", "recv", "(", "self", ",", "bufsize", "=", "DEFAULT_PACKET_BUFFER_SIZE", ")", ":", "if", "self", ".", "_handle", "is", "None", ":", "raise", "RuntimeError", "(", "\"WinDivert handle is not open\"", ")", "packet", "=", "bytearray", "(", "bufsize", ")", "p...
Receives a diverted packet that matched the filter. The remapped function is WinDivertRecv:: BOOL WinDivertRecv( __in HANDLE handle, __out PVOID pPacket, __in UINT packetLen, __out_opt PWINDIVERT_ADDRESS pAddr, __out_o...
[ "Receives", "a", "diverted", "packet", "that", "matched", "the", "filter", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert.py#L172-L202
train
ffalcinelli/pydivert
pydivert/windivert.py
WinDivert.send
def send(self, packet, recalculate_checksum=True): """ Injects a packet into the network stack. Recalculates the checksum before sending unless recalculate_checksum=False is passed. The injected packet may be one received from recv(), or a modified version, or a completely new packet. ...
python
def send(self, packet, recalculate_checksum=True): """ Injects a packet into the network stack. Recalculates the checksum before sending unless recalculate_checksum=False is passed. The injected packet may be one received from recv(), or a modified version, or a completely new packet. ...
[ "def", "send", "(", "self", ",", "packet", ",", "recalculate_checksum", "=", "True", ")", ":", "if", "recalculate_checksum", ":", "packet", ".", "recalculate_checksums", "(", ")", "send_len", "=", "c_uint", "(", "0", ")", "if", "PY2", ":", "# .from_buffer(me...
Injects a packet into the network stack. Recalculates the checksum before sending unless recalculate_checksum=False is passed. The injected packet may be one received from recv(), or a modified version, or a completely new packet. Injected packets can be captured and diverted again by other Win...
[ "Injects", "a", "packet", "into", "the", "network", "stack", ".", "Recalculates", "the", "checksum", "before", "sending", "unless", "recalculate_checksum", "=", "False", "is", "passed", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert.py#L204-L238
train
ffalcinelli/pydivert
pydivert/windivert.py
WinDivert.get_param
def get_param(self, name): """ Get a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is WinDivertGetParam:: BOOL WinDivertGetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __out UINT64...
python
def get_param(self, name): """ Get a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is WinDivertGetParam:: BOOL WinDivertGetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __out UINT64...
[ "def", "get_param", "(", "self", ",", "name", ")", ":", "value", "=", "c_uint64", "(", "0", ")", "windivert_dll", ".", "WinDivertGetParam", "(", "self", ".", "_handle", ",", "name", ",", "byref", "(", "value", ")", ")", "return", "value", ".", "value" ...
Get a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is WinDivertGetParam:: BOOL WinDivertGetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __out UINT64 *pValue ); For more info ...
[ "Get", "a", "WinDivert", "parameter", ".", "See", "pydivert", ".", "Param", "for", "the", "list", "of", "parameters", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert.py#L240-L258
train
ffalcinelli/pydivert
pydivert/windivert.py
WinDivert.set_param
def set_param(self, name, value): """ Set a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is DivertSetParam:: BOOL WinDivertSetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __in UIN...
python
def set_param(self, name, value): """ Set a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is DivertSetParam:: BOOL WinDivertSetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __in UIN...
[ "def", "set_param", "(", "self", ",", "name", ",", "value", ")", ":", "return", "windivert_dll", ".", "WinDivertSetParam", "(", "self", ".", "_handle", ",", "name", ",", "value", ")" ]
Set a WinDivert parameter. See pydivert.Param for the list of parameters. The remapped function is DivertSetParam:: BOOL WinDivertSetParam( __in HANDLE handle, __in WINDIVERT_PARAM param, __in UINT64 value ); For more info on the...
[ "Set", "a", "WinDivert", "parameter", ".", "See", "pydivert", ".", "Param", "for", "the", "list", "of", "parameters", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert.py#L260-L274
train
ffalcinelli/pydivert
pydivert/windivert_dll/__init__.py
_init
def _init(): """ Lazy-load DLL, replace proxy functions with actual ones. """ i = instance() for funcname in WINDIVERT_FUNCTIONS: func = getattr(i, funcname) func = raise_on_error(func) setattr(_module, funcname, func)
python
def _init(): """ Lazy-load DLL, replace proxy functions with actual ones. """ i = instance() for funcname in WINDIVERT_FUNCTIONS: func = getattr(i, funcname) func = raise_on_error(func) setattr(_module, funcname, func)
[ "def", "_init", "(", ")", ":", "i", "=", "instance", "(", ")", "for", "funcname", "in", "WINDIVERT_FUNCTIONS", ":", "func", "=", "getattr", "(", "i", ",", "funcname", ")", "func", "=", "raise_on_error", "(", "func", ")", "setattr", "(", "_module", ",",...
Lazy-load DLL, replace proxy functions with actual ones.
[ "Lazy", "-", "load", "DLL", "replace", "proxy", "functions", "with", "actual", "ones", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert_dll/__init__.py#L99-L107
train
ffalcinelli/pydivert
pydivert/windivert_dll/__init__.py
_mkprox
def _mkprox(funcname): """ Make lazy-init proxy function. """ def prox(*args, **kwargs): _init() return getattr(_module, funcname)(*args, **kwargs) return prox
python
def _mkprox(funcname): """ Make lazy-init proxy function. """ def prox(*args, **kwargs): _init() return getattr(_module, funcname)(*args, **kwargs) return prox
[ "def", "_mkprox", "(", "funcname", ")", ":", "def", "prox", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_init", "(", ")", "return", "getattr", "(", "_module", ",", "funcname", ")", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return...
Make lazy-init proxy function.
[ "Make", "lazy", "-", "init", "proxy", "function", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/windivert_dll/__init__.py#L110-L119
train
ffalcinelli/pydivert
pydivert/packet/ip.py
IPHeader.src_addr
def src_addr(self): """ The packet source address. """ try: return socket.inet_ntop(self._af, self.raw[self._src_addr].tobytes()) except (ValueError, socket.error): pass
python
def src_addr(self): """ The packet source address. """ try: return socket.inet_ntop(self._af, self.raw[self._src_addr].tobytes()) except (ValueError, socket.error): pass
[ "def", "src_addr", "(", "self", ")", ":", "try", ":", "return", "socket", ".", "inet_ntop", "(", "self", ".", "_af", ",", "self", ".", "raw", "[", "self", ".", "_src_addr", "]", ".", "tobytes", "(", ")", ")", "except", "(", "ValueError", ",", "sock...
The packet source address.
[ "The", "packet", "source", "address", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/ip.py#L29-L36
train
ffalcinelli/pydivert
pydivert/packet/ip.py
IPHeader.dst_addr
def dst_addr(self): """ The packet destination address. """ try: return socket.inet_ntop(self._af, self.raw[self._dst_addr].tobytes()) except (ValueError, socket.error): pass
python
def dst_addr(self): """ The packet destination address. """ try: return socket.inet_ntop(self._af, self.raw[self._dst_addr].tobytes()) except (ValueError, socket.error): pass
[ "def", "dst_addr", "(", "self", ")", ":", "try", ":", "return", "socket", ".", "inet_ntop", "(", "self", ".", "_af", ",", "self", ".", "raw", "[", "self", ".", "_dst_addr", "]", ".", "tobytes", "(", ")", ")", "except", "(", "ValueError", ",", "sock...
The packet destination address.
[ "The", "packet", "destination", "address", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/ip.py#L43-L50
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet.icmpv4
def icmpv4(self): """ - An ICMPv4Header instance, if the packet is valid ICMPv4. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.ICMP: return ICMPv4Header(self, proto_start)
python
def icmpv4(self): """ - An ICMPv4Header instance, if the packet is valid ICMPv4. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.ICMP: return ICMPv4Header(self, proto_start)
[ "def", "icmpv4", "(", "self", ")", ":", "ipproto", ",", "proto_start", "=", "self", ".", "protocol", "if", "ipproto", "==", "Protocol", ".", "ICMP", ":", "return", "ICMPv4Header", "(", "self", ",", "proto_start", ")" ]
- An ICMPv4Header instance, if the packet is valid ICMPv4. - None, otherwise.
[ "-", "An", "ICMPv4Header", "instance", "if", "the", "packet", "is", "valid", "ICMPv4", ".", "-", "None", "otherwise", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L176-L183
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet.icmpv6
def icmpv6(self): """ - An ICMPv6Header instance, if the packet is valid ICMPv6. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.ICMPV6: return ICMPv6Header(self, proto_start)
python
def icmpv6(self): """ - An ICMPv6Header instance, if the packet is valid ICMPv6. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.ICMPV6: return ICMPv6Header(self, proto_start)
[ "def", "icmpv6", "(", "self", ")", ":", "ipproto", ",", "proto_start", "=", "self", ".", "protocol", "if", "ipproto", "==", "Protocol", ".", "ICMPV6", ":", "return", "ICMPv6Header", "(", "self", ",", "proto_start", ")" ]
- An ICMPv6Header instance, if the packet is valid ICMPv6. - None, otherwise.
[ "-", "An", "ICMPv6Header", "instance", "if", "the", "packet", "is", "valid", "ICMPv6", ".", "-", "None", "otherwise", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L186-L193
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet.tcp
def tcp(self): """ - An TCPHeader instance, if the packet is valid TCP. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.TCP: return TCPHeader(self, proto_start)
python
def tcp(self): """ - An TCPHeader instance, if the packet is valid TCP. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.TCP: return TCPHeader(self, proto_start)
[ "def", "tcp", "(", "self", ")", ":", "ipproto", ",", "proto_start", "=", "self", ".", "protocol", "if", "ipproto", "==", "Protocol", ".", "TCP", ":", "return", "TCPHeader", "(", "self", ",", "proto_start", ")" ]
- An TCPHeader instance, if the packet is valid TCP. - None, otherwise.
[ "-", "An", "TCPHeader", "instance", "if", "the", "packet", "is", "valid", "TCP", ".", "-", "None", "otherwise", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L204-L211
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet.udp
def udp(self): """ - An TCPHeader instance, if the packet is valid UDP. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.UDP: return UDPHeader(self, proto_start)
python
def udp(self): """ - An TCPHeader instance, if the packet is valid UDP. - None, otherwise. """ ipproto, proto_start = self.protocol if ipproto == Protocol.UDP: return UDPHeader(self, proto_start)
[ "def", "udp", "(", "self", ")", ":", "ipproto", ",", "proto_start", "=", "self", ".", "protocol", "if", "ipproto", "==", "Protocol", ".", "UDP", ":", "return", "UDPHeader", "(", "self", ",", "proto_start", ")" ]
- An TCPHeader instance, if the packet is valid UDP. - None, otherwise.
[ "-", "An", "TCPHeader", "instance", "if", "the", "packet", "is", "valid", "UDP", ".", "-", "None", "otherwise", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L214-L221
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet._payload
def _payload(self): """header that implements PayloadMixin""" return self.tcp or self.udp or self.icmpv4 or self.icmpv6
python
def _payload(self): """header that implements PayloadMixin""" return self.tcp or self.udp or self.icmpv4 or self.icmpv6
[ "def", "_payload", "(", "self", ")", ":", "return", "self", ".", "tcp", "or", "self", ".", "udp", "or", "self", ".", "icmpv4", "or", "self", ".", "icmpv6" ]
header that implements PayloadMixin
[ "header", "that", "implements", "PayloadMixin" ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L229-L231
train
ffalcinelli/pydivert
pydivert/packet/__init__.py
Packet.matches
def matches(self, filter, layer=Layer.NETWORK): """ Evaluates the packet against the given packet filter string. The remapped function is:: BOOL WinDivertHelperEvalFilter( __in const char *filter, __in WINDIVERT_LAYER layer, __in PVOI...
python
def matches(self, filter, layer=Layer.NETWORK): """ Evaluates the packet against the given packet filter string. The remapped function is:: BOOL WinDivertHelperEvalFilter( __in const char *filter, __in WINDIVERT_LAYER layer, __in PVOI...
[ "def", "matches", "(", "self", ",", "filter", ",", "layer", "=", "Layer", ".", "NETWORK", ")", ":", "buff", ",", "buff_", "=", "self", ".", "__to_buffers", "(", ")", "return", "windivert_dll", ".", "WinDivertHelperEvalFilter", "(", "filter", ".", "encode",...
Evaluates the packet against the given packet filter string. The remapped function is:: BOOL WinDivertHelperEvalFilter( __in const char *filter, __in WINDIVERT_LAYER layer, __in PVOID pPacket, __in UINT packetLen, __in...
[ "Evaluates", "the", "packet", "against", "the", "given", "packet", "filter", "string", "." ]
f75eba4126c527b5a43ace0a49369c7479cf5ee8
https://github.com/ffalcinelli/pydivert/blob/f75eba4126c527b5a43ace0a49369c7479cf5ee8/pydivert/packet/__init__.py#L328-L350
train
floydhub/floyd-cli
floyd/cli/experiment.py
init
def init(project_name): """ Initialize new project at the current path. After this you can run other FloydHub commands like status and run. """ project_obj = ProjectClient().get_by_name(project_name) if not project_obj: namespace, name = get_namespace_from_name(project_name) c...
python
def init(project_name): """ Initialize new project at the current path. After this you can run other FloydHub commands like status and run. """ project_obj = ProjectClient().get_by_name(project_name) if not project_obj: namespace, name = get_namespace_from_name(project_name) c...
[ "def", "init", "(", "project_name", ")", ":", "project_obj", "=", "ProjectClient", "(", ")", ".", "get_by_name", "(", "project_name", ")", "if", "not", "project_obj", ":", "namespace", ",", "name", "=", "get_namespace_from_name", "(", "project_name", ")", "cre...
Initialize new project at the current path. After this you can run other FloydHub commands like status and run.
[ "Initialize", "new", "project", "at", "the", "current", "path", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L40-L77
train
floydhub/floyd-cli
floyd/cli/experiment.py
status
def status(id): """ View status of all jobs in a project. The command also accepts a specific job name. """ if id: try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) print_e...
python
def status(id): """ View status of all jobs in a project. The command also accepts a specific job name. """ if id: try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) print_e...
[ "def", "status", "(", "id", ")", ":", "if", "id", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "id", ")", ")", "except", "FloydException", ":", "experiment", "=", "ExperimentClient", "(", "...
View status of all jobs in a project. The command also accepts a specific job name.
[ "View", "status", "of", "all", "jobs", "in", "a", "project", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L82-L97
train
floydhub/floyd-cli
floyd/cli/experiment.py
print_experiments
def print_experiments(experiments): """ Prints job details in a table. Includes urls and mode parameters """ headers = ["JOB NAME", "CREATED", "STATUS", "DURATION(s)", "INSTANCE", "DESCRIPTION", "METRICS"] expt_list = [] for experiment in experiments: expt_list.append([normalize_job_name...
python
def print_experiments(experiments): """ Prints job details in a table. Includes urls and mode parameters """ headers = ["JOB NAME", "CREATED", "STATUS", "DURATION(s)", "INSTANCE", "DESCRIPTION", "METRICS"] expt_list = [] for experiment in experiments: expt_list.append([normalize_job_name...
[ "def", "print_experiments", "(", "experiments", ")", ":", "headers", "=", "[", "\"JOB NAME\"", ",", "\"CREATED\"", ",", "\"STATUS\"", ",", "\"DURATION(s)\"", ",", "\"INSTANCE\"", ",", "\"DESCRIPTION\"", ",", "\"METRICS\"", "]", "expt_list", "=", "[", "]", "for",...
Prints job details in a table. Includes urls and mode parameters
[ "Prints", "job", "details", "in", "a", "table", ".", "Includes", "urls", "and", "mode", "parameters" ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L100-L111
train
floydhub/floyd-cli
floyd/cli/experiment.py
clone
def clone(id, path): """ - Download all files from a job Eg: alice/projects/mnist/1/ Note: This will download the files that were originally uploaded at the start of the job. - Download files in a specific path from a job Specify the path to a directory and download all its files and sub...
python
def clone(id, path): """ - Download all files from a job Eg: alice/projects/mnist/1/ Note: This will download the files that were originally uploaded at the start of the job. - Download files in a specific path from a job Specify the path to a directory and download all its files and sub...
[ "def", "clone", "(", "id", ",", "path", ")", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "id", ",", "use_config", "=", "False", ")", ")", "except", "FloydException", ":", "experiment", "="...
- Download all files from a job Eg: alice/projects/mnist/1/ Note: This will download the files that were originally uploaded at the start of the job. - Download files in a specific path from a job Specify the path to a directory and download all its files and subdirectories. Eg: --path mode...
[ "-", "Download", "all", "files", "from", "a", "job" ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L124-L161
train
floydhub/floyd-cli
floyd/cli/experiment.py
info
def info(job_name_or_id): """ View detailed information of a job. """ try: experiment = ExperimentClient().get(normalize_job_name(job_name_or_id)) except FloydException: experiment = ExperimentClient().get(job_name_or_id) task_instance_id = get_module_task_instance_id(experiment...
python
def info(job_name_or_id): """ View detailed information of a job. """ try: experiment = ExperimentClient().get(normalize_job_name(job_name_or_id)) except FloydException: experiment = ExperimentClient().get(job_name_or_id) task_instance_id = get_module_task_instance_id(experiment...
[ "def", "info", "(", "job_name_or_id", ")", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "job_name_or_id", ")", ")", "except", "FloydException", ":", "experiment", "=", "ExperimentClient", "(", ")...
View detailed information of a job.
[ "View", "detailed", "information", "of", "a", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L166-L189
train
floydhub/floyd-cli
floyd/cli/experiment.py
follow_logs
def follow_logs(instance_log_id, sleep_duration=1): """ Follow the logs until Job termination. """ cur_idx = 0 job_terminated = False while not job_terminated: # Get the logs in a loop and log the new lines log_file_contents = ResourceClient().get_content(instance_log_id) ...
python
def follow_logs(instance_log_id, sleep_duration=1): """ Follow the logs until Job termination. """ cur_idx = 0 job_terminated = False while not job_terminated: # Get the logs in a loop and log the new lines log_file_contents = ResourceClient().get_content(instance_log_id) ...
[ "def", "follow_logs", "(", "instance_log_id", ",", "sleep_duration", "=", "1", ")", ":", "cur_idx", "=", "0", "job_terminated", "=", "False", "while", "not", "job_terminated", ":", "# Get the logs in a loop and log the new lines", "log_file_contents", "=", "ResourceClie...
Follow the logs until Job termination.
[ "Follow", "the", "logs", "until", "Job", "termination", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L212-L227
train
floydhub/floyd-cli
floyd/cli/experiment.py
logs
def logs(id, url, follow, sleep_duration=1): """ View the logs of a job. To follow along a job in real time, use the --follow flag """ instance_log_id = get_log_id(id) if url: log_url = "{}/api/v1/resources/{}?content=true".format( floyd.floyd_host, instance_log_id) ...
python
def logs(id, url, follow, sleep_duration=1): """ View the logs of a job. To follow along a job in real time, use the --follow flag """ instance_log_id = get_log_id(id) if url: log_url = "{}/api/v1/resources/{}?content=true".format( floyd.floyd_host, instance_log_id) ...
[ "def", "logs", "(", "id", ",", "url", ",", "follow", ",", "sleep_duration", "=", "1", ")", ":", "instance_log_id", "=", "get_log_id", "(", "id", ")", "if", "url", ":", "log_url", "=", "\"{}/api/v1/resources/{}?content=true\"", ".", "format", "(", "floyd", ...
View the logs of a job. To follow along a job in real time, use the --follow flag
[ "View", "the", "logs", "of", "a", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L234-L256
train
floydhub/floyd-cli
floyd/cli/experiment.py
output
def output(id, url): """ View the files from a job. """ try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) output_dir_url = "%s/%s/files" % (floyd.floyd_web_host, experiment.name) if url: fl...
python
def output(id, url): """ View the files from a job. """ try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) output_dir_url = "%s/%s/files" % (floyd.floyd_web_host, experiment.name) if url: fl...
[ "def", "output", "(", "id", ",", "url", ")", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "id", ")", ")", "except", "FloydException", ":", "experiment", "=", "ExperimentClient", "(", ")", "...
View the files from a job.
[ "View", "the", "files", "from", "a", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L262-L276
train
floydhub/floyd-cli
floyd/cli/experiment.py
stop
def stop(id): """ Stop a running job. """ try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) if experiment.state not in ["queued", "queue_scheduled", "running"]: floyd_logger.info("Job in {} sta...
python
def stop(id): """ Stop a running job. """ try: experiment = ExperimentClient().get(normalize_job_name(id)) except FloydException: experiment = ExperimentClient().get(id) if experiment.state not in ["queued", "queue_scheduled", "running"]: floyd_logger.info("Job in {} sta...
[ "def", "stop", "(", "id", ")", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "id", ")", ")", "except", "FloydException", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "("...
Stop a running job.
[ "Stop", "a", "running", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L281-L298
train
floydhub/floyd-cli
floyd/cli/experiment.py
delete
def delete(names, yes): """ Delete a training job. """ failures = False for name in names: try: experiment = ExperimentClient().get(normalize_job_name(name)) except FloydException: experiment = ExperimentClient().get(name) if not experiment: ...
python
def delete(names, yes): """ Delete a training job. """ failures = False for name in names: try: experiment = ExperimentClient().get(normalize_job_name(name)) except FloydException: experiment = ExperimentClient().get(name) if not experiment: ...
[ "def", "delete", "(", "names", ",", "yes", ")", ":", "failures", "=", "False", "for", "name", "in", "names", ":", "try", ":", "experiment", "=", "ExperimentClient", "(", ")", ".", "get", "(", "normalize_job_name", "(", "name", ")", ")", "except", "Floy...
Delete a training job.
[ "Delete", "a", "training", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/experiment.py#L304-L331
train
floydhub/floyd-cli
floyd/cli/version.py
version
def version(): """ View the current version of the CLI. """ import pkg_resources version = pkg_resources.require(PROJECT_NAME)[0].version floyd_logger.info(version)
python
def version(): """ View the current version of the CLI. """ import pkg_resources version = pkg_resources.require(PROJECT_NAME)[0].version floyd_logger.info(version)
[ "def", "version", "(", ")", ":", "import", "pkg_resources", "version", "=", "pkg_resources", ".", "require", "(", "PROJECT_NAME", ")", "[", "0", "]", ".", "version", "floyd_logger", ".", "info", "(", "version", ")" ]
View the current version of the CLI.
[ "View", "the", "current", "version", "of", "the", "CLI", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/version.py#L21-L27
train
floydhub/floyd-cli
floyd/cli/data.py
init
def init(dataset_name): """ Initialize a new dataset at the current dir. Then run the upload command to copy all the files in this directory to FloydHub. floyd data upload """ dataset_obj = DatasetClient().get_by_name(dataset_name) if not dataset_obj: namespace, name = get...
python
def init(dataset_name): """ Initialize a new dataset at the current dir. Then run the upload command to copy all the files in this directory to FloydHub. floyd data upload """ dataset_obj = DatasetClient().get_by_name(dataset_name) if not dataset_obj: namespace, name = get...
[ "def", "init", "(", "dataset_name", ")", ":", "dataset_obj", "=", "DatasetClient", "(", ")", ".", "get_by_name", "(", "dataset_name", ")", "if", "not", "dataset_obj", ":", "namespace", ",", "name", "=", "get_namespace_from_name", "(", "dataset_name", ")", "cre...
Initialize a new dataset at the current dir. Then run the upload command to copy all the files in this directory to FloydHub. floyd data upload
[ "Initialize", "a", "new", "dataset", "at", "the", "current", "dir", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L37-L74
train
floydhub/floyd-cli
floyd/cli/data.py
upload
def upload(resume, message): """ Upload files in the current dir to FloydHub. """ data_config = DataConfigManager.get_config() if not upload_is_resumable(data_config) or not opt_to_resume(resume): abort_previous_upload(data_config) access_token = AuthConfigManager.get_access_token()...
python
def upload(resume, message): """ Upload files in the current dir to FloydHub. """ data_config = DataConfigManager.get_config() if not upload_is_resumable(data_config) or not opt_to_resume(resume): abort_previous_upload(data_config) access_token = AuthConfigManager.get_access_token()...
[ "def", "upload", "(", "resume", ",", "message", ")", ":", "data_config", "=", "DataConfigManager", ".", "get_config", "(", ")", "if", "not", "upload_is_resumable", "(", "data_config", ")", "or", "not", "opt_to_resume", "(", "resume", ")", ":", "abort_previous_...
Upload files in the current dir to FloydHub.
[ "Upload", "files", "in", "the", "current", "dir", "to", "FloydHub", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L82-L93
train
floydhub/floyd-cli
floyd/cli/data.py
status
def status(id): """ View status of all versions in a dataset. The command also accepts a specific dataset version. """ if id: data_source = get_data_object(id, use_data_config=False) print_data([data_source] if data_source else []) else: data_sources = DataClient().get_a...
python
def status(id): """ View status of all versions in a dataset. The command also accepts a specific dataset version. """ if id: data_source = get_data_object(id, use_data_config=False) print_data([data_source] if data_source else []) else: data_sources = DataClient().get_a...
[ "def", "status", "(", "id", ")", ":", "if", "id", ":", "data_source", "=", "get_data_object", "(", "id", ",", "use_data_config", "=", "False", ")", "print_data", "(", "[", "data_source", "]", "if", "data_source", "else", "[", "]", ")", "else", ":", "da...
View status of all versions in a dataset. The command also accepts a specific dataset version.
[ "View", "status", "of", "all", "versions", "in", "a", "dataset", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L98-L109
train
floydhub/floyd-cli
floyd/cli/data.py
get_data_object
def get_data_object(data_id, use_data_config=True): """ Normalize the data_id and query the server. If that is unavailable try the raw ID """ normalized_data_reference = normalize_data_name(data_id, use_data_config=use_data_config) client = DataClient() data_obj = client.get(normalized_data_...
python
def get_data_object(data_id, use_data_config=True): """ Normalize the data_id and query the server. If that is unavailable try the raw ID """ normalized_data_reference = normalize_data_name(data_id, use_data_config=use_data_config) client = DataClient() data_obj = client.get(normalized_data_...
[ "def", "get_data_object", "(", "data_id", ",", "use_data_config", "=", "True", ")", ":", "normalized_data_reference", "=", "normalize_data_name", "(", "data_id", ",", "use_data_config", "=", "use_data_config", ")", "client", "=", "DataClient", "(", ")", "data_obj", ...
Normalize the data_id and query the server. If that is unavailable try the raw ID
[ "Normalize", "the", "data_id", "and", "query", "the", "server", ".", "If", "that", "is", "unavailable", "try", "the", "raw", "ID" ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L112-L125
train
floydhub/floyd-cli
floyd/cli/data.py
print_data
def print_data(data_sources): """ Print dataset information in tabular form """ if not data_sources: return headers = ["DATA NAME", "CREATED", "STATUS", "DISK USAGE"] data_list = [] for data_source in data_sources: data_list.append([data_source.name, ...
python
def print_data(data_sources): """ Print dataset information in tabular form """ if not data_sources: return headers = ["DATA NAME", "CREATED", "STATUS", "DISK USAGE"] data_list = [] for data_source in data_sources: data_list.append([data_source.name, ...
[ "def", "print_data", "(", "data_sources", ")", ":", "if", "not", "data_sources", ":", "return", "headers", "=", "[", "\"DATA NAME\"", ",", "\"CREATED\"", ",", "\"STATUS\"", ",", "\"DISK USAGE\"", "]", "data_list", "=", "[", "]", "for", "data_source", "in", "...
Print dataset information in tabular form
[ "Print", "dataset", "information", "in", "tabular", "form" ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L128-L141
train
floydhub/floyd-cli
floyd/cli/data.py
clone
def clone(id, path): """ - Download all files in a dataset or from a Job output Eg: alice/projects/mnist/1/files, alice/projects/mnist/1/output or alice/dataset/mnist-data/1/ Using /output will download the files that are saved at the end of the job. Note: This will download the files that are sa...
python
def clone(id, path): """ - Download all files in a dataset or from a Job output Eg: alice/projects/mnist/1/files, alice/projects/mnist/1/output or alice/dataset/mnist-data/1/ Using /output will download the files that are saved at the end of the job. Note: This will download the files that are sa...
[ "def", "clone", "(", "id", ",", "path", ")", ":", "data_source", "=", "get_data_object", "(", "id", ",", "use_data_config", "=", "False", ")", "if", "not", "data_source", ":", "if", "'output'", "in", "id", ":", "floyd_logger", ".", "info", "(", "\"Note: ...
- Download all files in a dataset or from a Job output Eg: alice/projects/mnist/1/files, alice/projects/mnist/1/output or alice/dataset/mnist-data/1/ Using /output will download the files that are saved at the end of the job. Note: This will download the files that are saved at the end of the job. ...
[ "-", "Download", "all", "files", "in", "a", "dataset", "or", "from", "a", "Job", "output" ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L148-L196
train
floydhub/floyd-cli
floyd/cli/data.py
listfiles
def listfiles(data_name): """ List files in a dataset. """ data_source = get_data_object(data_name, use_data_config=False) if not data_source: if 'output' in data_name: floyd_logger.info("Note: You cannot clone the output of a running job. You need to wait for it to finish.") ...
python
def listfiles(data_name): """ List files in a dataset. """ data_source = get_data_object(data_name, use_data_config=False) if not data_source: if 'output' in data_name: floyd_logger.info("Note: You cannot clone the output of a running job. You need to wait for it to finish.") ...
[ "def", "listfiles", "(", "data_name", ")", ":", "data_source", "=", "get_data_object", "(", "data_name", ",", "use_data_config", "=", "False", ")", "if", "not", "data_source", ":", "if", "'output'", "in", "data_name", ":", "floyd_logger", ".", "info", "(", "...
List files in a dataset.
[ "List", "files", "in", "a", "dataset", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L201-L235
train
floydhub/floyd-cli
floyd/cli/data.py
getfile
def getfile(data_name, path): """ Download a specific file from a dataset. """ data_source = get_data_object(data_name, use_data_config=False) if not data_source: if 'output' in data_name: floyd_logger.info("Note: You cannot clone the output of a running job. You need to wait f...
python
def getfile(data_name, path): """ Download a specific file from a dataset. """ data_source = get_data_object(data_name, use_data_config=False) if not data_source: if 'output' in data_name: floyd_logger.info("Note: You cannot clone the output of a running job. You need to wait f...
[ "def", "getfile", "(", "data_name", ",", "path", ")", ":", "data_source", "=", "get_data_object", "(", "data_name", ",", "use_data_config", "=", "False", ")", "if", "not", "data_source", ":", "if", "'output'", "in", "data_name", ":", "floyd_logger", ".", "in...
Download a specific file from a dataset.
[ "Download", "a", "specific", "file", "from", "a", "dataset", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L241-L256
train
floydhub/floyd-cli
floyd/cli/data.py
output
def output(id, url): """ View the files from a dataset. """ data_source = get_data_object(id, use_data_config=False) if not data_source: sys.exit() data_url = "%s/%s" % (floyd.floyd_web_host, data_source.name) if url: floyd_logger.info(data_url) else: floyd_logg...
python
def output(id, url): """ View the files from a dataset. """ data_source = get_data_object(id, use_data_config=False) if not data_source: sys.exit() data_url = "%s/%s" % (floyd.floyd_web_host, data_source.name) if url: floyd_logger.info(data_url) else: floyd_logg...
[ "def", "output", "(", "id", ",", "url", ")", ":", "data_source", "=", "get_data_object", "(", "id", ",", "use_data_config", "=", "False", ")", "if", "not", "data_source", ":", "sys", ".", "exit", "(", ")", "data_url", "=", "\"%s/%s\"", "%", "(", "floyd...
View the files from a dataset.
[ "View", "the", "files", "from", "a", "dataset", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L263-L277
train
floydhub/floyd-cli
floyd/cli/data.py
delete
def delete(ids, yes): """ Delete datasets. """ failures = False for id in ids: data_source = get_data_object(id, use_data_config=True) if not data_source: failures = True continue data_name = normalize_data_name(data_source.name) suffix = da...
python
def delete(ids, yes): """ Delete datasets. """ failures = False for id in ids: data_source = get_data_object(id, use_data_config=True) if not data_source: failures = True continue data_name = normalize_data_name(data_source.name) suffix = da...
[ "def", "delete", "(", "ids", ",", "yes", ")", ":", "failures", "=", "False", "for", "id", "in", "ids", ":", "data_source", "=", "get_data_object", "(", "id", ",", "use_data_config", "=", "True", ")", "if", "not", "data_source", ":", "failures", "=", "T...
Delete datasets.
[ "Delete", "datasets", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L284-L318
train
floydhub/floyd-cli
floyd/cli/data.py
add
def add(source): """ Create a new dataset version from the contents of a job. This will create a new dataset version with the job output. Use the full job name: foo/projects/bar/1/code, foo/projects/bar/1/files or foo/projects/bar/1/output """ new_data = DatasetClient().add_data(source) pri...
python
def add(source): """ Create a new dataset version from the contents of a job. This will create a new dataset version with the job output. Use the full job name: foo/projects/bar/1/code, foo/projects/bar/1/files or foo/projects/bar/1/output """ new_data = DatasetClient().add_data(source) pri...
[ "def", "add", "(", "source", ")", ":", "new_data", "=", "DatasetClient", "(", ")", ".", "add_data", "(", "source", ")", "print_data", "(", "[", "DataClient", "(", ")", ".", "get", "(", "new_data", "[", "'data_id'", "]", ")", "]", ")" ]
Create a new dataset version from the contents of a job. This will create a new dataset version with the job output. Use the full job name: foo/projects/bar/1/code, foo/projects/bar/1/files or foo/projects/bar/1/output
[ "Create", "a", "new", "dataset", "version", "from", "the", "contents", "of", "a", "job", "." ]
ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c
https://github.com/floydhub/floyd-cli/blob/ea6b9521119cbde2dfc71ce0cc87c0d9c143fc6c/floyd/cli/data.py#L323-L331
train