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
GNS3/gns3-server
gns3server/controller/topology.py
_convert_snapshots
def _convert_snapshots(topo_dir): """ Convert 1.x snapshot to the new format """ old_snapshots_dir = os.path.join(topo_dir, "project-files", "snapshots") if os.path.exists(old_snapshots_dir): new_snapshots_dir = os.path.join(topo_dir, "snapshots") os.makedirs(new_snapshots_dir) ...
python
def _convert_snapshots(topo_dir): """ Convert 1.x snapshot to the new format """ old_snapshots_dir = os.path.join(topo_dir, "project-files", "snapshots") if os.path.exists(old_snapshots_dir): new_snapshots_dir = os.path.join(topo_dir, "snapshots") os.makedirs(new_snapshots_dir) ...
[ "def", "_convert_snapshots", "(", "topo_dir", ")", ":", "old_snapshots_dir", "=", "os", ".", "path", ".", "join", "(", "topo_dir", ",", "\"project-files\"", ",", "\"snapshots\"", ")", "if", "os", ".", "path", ".", "exists", "(", "old_snapshots_dir", ")", ":"...
Convert 1.x snapshot to the new format
[ "Convert", "1", ".", "x", "snapshot", "to", "the", "new", "format" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L638-L665
train
GNS3/gns3-server
gns3server/controller/topology.py
_convert_qemu_node
def _convert_qemu_node(node, old_node): """ Convert qemu node from 1.X to 2.0 """ # In 2.0 the internet VM is replaced by the NAT node if old_node.get("properties", {}).get("hda_disk_image_md5sum") == "8ebc5a6ec53a1c05b7aa101b5ceefe31": node["console"] = None node["console_type"] = ...
python
def _convert_qemu_node(node, old_node): """ Convert qemu node from 1.X to 2.0 """ # In 2.0 the internet VM is replaced by the NAT node if old_node.get("properties", {}).get("hda_disk_image_md5sum") == "8ebc5a6ec53a1c05b7aa101b5ceefe31": node["console"] = None node["console_type"] = ...
[ "def", "_convert_qemu_node", "(", "node", ",", "old_node", ")", ":", "# In 2.0 the internet VM is replaced by the NAT node", "if", "old_node", ".", "get", "(", "\"properties\"", ",", "{", "}", ")", ".", "get", "(", "\"hda_disk_image_md5sum\"", ")", "==", "\"8ebc5a6e...
Convert qemu node from 1.X to 2.0
[ "Convert", "qemu", "node", "from", "1", ".", "X", "to", "2", ".", "0" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/topology.py#L668-L696
train
GNS3/gns3-server
gns3server/controller/project.py
open_required
def open_required(func): """ Use this decorator to raise an error if the project is not opened """ def wrapper(self, *args, **kwargs): if self._status == "closed": raise aiohttp.web.HTTPForbidden(text="The project is not opened") return func(self, *args, **kwargs) return...
python
def open_required(func): """ Use this decorator to raise an error if the project is not opened """ def wrapper(self, *args, **kwargs): if self._status == "closed": raise aiohttp.web.HTTPForbidden(text="The project is not opened") return func(self, *args, **kwargs) return...
[ "def", "open_required", "(", "func", ")", ":", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_status", "==", "\"closed\"", ":", "raise", "aiohttp", ".", "web", ".", "HTTPForbidden", "(", "text...
Use this decorator to raise an error if the project is not opened
[ "Use", "this", "decorator", "to", "raise", "an", "error", "if", "the", "project", "is", "not", "opened" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L47-L56
train
GNS3/gns3-server
gns3server/controller/project.py
Project.captures_directory
def captures_directory(self): """ Location of the captures files """ path = os.path.join(self._path, "project-files", "captures") os.makedirs(path, exist_ok=True) return path
python
def captures_directory(self): """ Location of the captures files """ path = os.path.join(self._path, "project-files", "captures") os.makedirs(path, exist_ok=True) return path
[ "def", "captures_directory", "(", "self", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_path", ",", "\"project-files\"", ",", "\"captures\"", ")", "os", ".", "makedirs", "(", "path", ",", "exist_ok", "=", "True", ")", "retu...
Location of the captures files
[ "Location", "of", "the", "captures", "files" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L325-L331
train
GNS3/gns3-server
gns3server/controller/project.py
Project.remove_allocated_node_name
def remove_allocated_node_name(self, name): """ Removes an allocated node name :param name: allocated node name """ if name in self._allocated_node_names: self._allocated_node_names.remove(name)
python
def remove_allocated_node_name(self, name): """ Removes an allocated node name :param name: allocated node name """ if name in self._allocated_node_names: self._allocated_node_names.remove(name)
[ "def", "remove_allocated_node_name", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_allocated_node_names", ":", "self", ".", "_allocated_node_names", ".", "remove", "(", "name", ")" ]
Removes an allocated node name :param name: allocated node name
[ "Removes", "an", "allocated", "node", "name" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L349-L357
train
GNS3/gns3-server
gns3server/controller/project.py
Project.update_allocated_node_name
def update_allocated_node_name(self, base_name): """ Updates a node name or generate a new if no node name is available. :param base_name: new node base name """ if base_name is None: return None base_name = re.sub(r"[ ]", "", base_name) if b...
python
def update_allocated_node_name(self, base_name): """ Updates a node name or generate a new if no node name is available. :param base_name: new node base name """ if base_name is None: return None base_name = re.sub(r"[ ]", "", base_name) if b...
[ "def", "update_allocated_node_name", "(", "self", ",", "base_name", ")", ":", "if", "base_name", "is", "None", ":", "return", "None", "base_name", "=", "re", ".", "sub", "(", "r\"[ ]\"", ",", "\"\"", ",", "base_name", ")", "if", "base_name", "in", "self", ...
Updates a node name or generate a new if no node name is available. :param base_name: new node base name
[ "Updates", "a", "node", "name", "or", "generate", "a", "new", "if", "no", "node", "name", "is", "available", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L359-L395
train
GNS3/gns3-server
gns3server/controller/project.py
Project.add_node_from_appliance
def add_node_from_appliance(self, appliance_id, x=0, y=0, compute_id=None): """ Create a node from an appliance """ try: template = self.controller.appliances[appliance_id].data except KeyError: msg = "Appliance {} doesn't exist".format(appliance_id) ...
python
def add_node_from_appliance(self, appliance_id, x=0, y=0, compute_id=None): """ Create a node from an appliance """ try: template = self.controller.appliances[appliance_id].data except KeyError: msg = "Appliance {} doesn't exist".format(appliance_id) ...
[ "def", "add_node_from_appliance", "(", "self", ",", "appliance_id", ",", "x", "=", "0", ",", "y", "=", "0", ",", "compute_id", "=", "None", ")", ":", "try", ":", "template", "=", "self", ".", "controller", ".", "appliances", "[", "appliance_id", "]", "...
Create a node from an appliance
[ "Create", "a", "node", "from", "an", "appliance" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L406-L425
train
GNS3/gns3-server
gns3server/controller/project.py
Project.add_node
def add_node(self, compute, name, node_id, dump=True, node_type=None, **kwargs): """ Create a node or return an existing node :param dump: Dump topology to disk :param kwargs: See the documentation of node """ if node_id in self._nodes: return self._nodes[no...
python
def add_node(self, compute, name, node_id, dump=True, node_type=None, **kwargs): """ Create a node or return an existing node :param dump: Dump topology to disk :param kwargs: See the documentation of node """ if node_id in self._nodes: return self._nodes[no...
[ "def", "add_node", "(", "self", ",", "compute", ",", "name", ",", "node_id", ",", "dump", "=", "True", ",", "node_type", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "node_id", "in", "self", ".", "_nodes", ":", "return", "self", ".", "_nod...
Create a node or return an existing node :param dump: Dump topology to disk :param kwargs: See the documentation of node
[ "Create", "a", "node", "or", "return", "an", "existing", "node" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L429-L461
train
GNS3/gns3-server
gns3server/controller/project.py
Project.__delete_node_links
def __delete_node_links(self, node): """ Delete all link connected to this node. The operation use a lock to avoid cleaning links from multiple nodes at the same time. """ for link in list(self._links.values()): if node in link.nodes: yield fr...
python
def __delete_node_links(self, node): """ Delete all link connected to this node. The operation use a lock to avoid cleaning links from multiple nodes at the same time. """ for link in list(self._links.values()): if node in link.nodes: yield fr...
[ "def", "__delete_node_links", "(", "self", ",", "node", ")", ":", "for", "link", "in", "list", "(", "self", ".", "_links", ".", "values", "(", ")", ")", ":", "if", "node", "in", "link", ".", "nodes", ":", "yield", "from", "self", ".", "delete_link", ...
Delete all link connected to this node. The operation use a lock to avoid cleaning links from multiple nodes at the same time.
[ "Delete", "all", "link", "connected", "to", "this", "node", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L464-L473
train
GNS3/gns3-server
gns3server/controller/project.py
Project.get_node
def get_node(self, node_id): """ Return the node or raise a 404 if the node is unknown """ try: return self._nodes[node_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Node ID {} doesn't exist".format(node_id))
python
def get_node(self, node_id): """ Return the node or raise a 404 if the node is unknown """ try: return self._nodes[node_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Node ID {} doesn't exist".format(node_id))
[ "def", "get_node", "(", "self", ",", "node_id", ")", ":", "try", ":", "return", "self", ".", "_nodes", "[", "node_id", "]", "except", "KeyError", ":", "raise", "aiohttp", ".", "web", ".", "HTTPNotFound", "(", "text", "=", "\"Node ID {} doesn't exist\"", "....
Return the node or raise a 404 if the node is unknown
[ "Return", "the", "node", "or", "raise", "a", "404", "if", "the", "node", "is", "unknown" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L487-L494
train
GNS3/gns3-server
gns3server/controller/project.py
Project.add_drawing
def add_drawing(self, drawing_id=None, dump=True, **kwargs): """ Create an drawing or return an existing drawing :param dump: Dump the topology to disk :param kwargs: See the documentation of drawing """ if drawing_id not in self._drawings: drawing = Drawing(...
python
def add_drawing(self, drawing_id=None, dump=True, **kwargs): """ Create an drawing or return an existing drawing :param dump: Dump the topology to disk :param kwargs: See the documentation of drawing """ if drawing_id not in self._drawings: drawing = Drawing(...
[ "def", "add_drawing", "(", "self", ",", "drawing_id", "=", "None", ",", "dump", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if", "drawing_id", "not", "in", "self", ".", "_drawings", ":", "drawing", "=", "Drawing", "(", "self", ",", "drawing_id", ...
Create an drawing or return an existing drawing :param dump: Dump the topology to disk :param kwargs: See the documentation of drawing
[ "Create", "an", "drawing", "or", "return", "an", "existing", "drawing" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L512-L526
train
GNS3/gns3-server
gns3server/controller/project.py
Project.get_drawing
def get_drawing(self, drawing_id): """ Return the Drawing or raise a 404 if the drawing is unknown """ try: return self._drawings[drawing_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Drawing ID {} doesn't exist".format(drawing_id))
python
def get_drawing(self, drawing_id): """ Return the Drawing or raise a 404 if the drawing is unknown """ try: return self._drawings[drawing_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Drawing ID {} doesn't exist".format(drawing_id))
[ "def", "get_drawing", "(", "self", ",", "drawing_id", ")", ":", "try", ":", "return", "self", ".", "_drawings", "[", "drawing_id", "]", "except", "KeyError", ":", "raise", "aiohttp", ".", "web", ".", "HTTPNotFound", "(", "text", "=", "\"Drawing ID {} doesn't...
Return the Drawing or raise a 404 if the drawing is unknown
[ "Return", "the", "Drawing", "or", "raise", "a", "404", "if", "the", "drawing", "is", "unknown" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L529-L536
train
GNS3/gns3-server
gns3server/controller/project.py
Project.add_link
def add_link(self, link_id=None, dump=True): """ Create a link. By default the link is empty :param dump: Dump topology to disk """ if link_id and link_id in self._links: return self._links[link_id] link = UDPLink(self, link_id=link_id) self._links[li...
python
def add_link(self, link_id=None, dump=True): """ Create a link. By default the link is empty :param dump: Dump topology to disk """ if link_id and link_id in self._links: return self._links[link_id] link = UDPLink(self, link_id=link_id) self._links[li...
[ "def", "add_link", "(", "self", ",", "link_id", "=", "None", ",", "dump", "=", "True", ")", ":", "if", "link_id", "and", "link_id", "in", "self", ".", "_links", ":", "return", "self", ".", "_links", "[", "link_id", "]", "link", "=", "UDPLink", "(", ...
Create a link. By default the link is empty :param dump: Dump topology to disk
[ "Create", "a", "link", ".", "By", "default", "the", "link", "is", "empty" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L548-L560
train
GNS3/gns3-server
gns3server/controller/project.py
Project.get_link
def get_link(self, link_id): """ Return the Link or raise a 404 if the link is unknown """ try: return self._links[link_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Link ID {} doesn't exist".format(link_id))
python
def get_link(self, link_id): """ Return the Link or raise a 404 if the link is unknown """ try: return self._links[link_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Link ID {} doesn't exist".format(link_id))
[ "def", "get_link", "(", "self", ",", "link_id", ")", ":", "try", ":", "return", "self", ".", "_links", "[", "link_id", "]", "except", "KeyError", ":", "raise", "aiohttp", ".", "web", ".", "HTTPNotFound", "(", "text", "=", "\"Link ID {} doesn't exist\"", "....
Return the Link or raise a 404 if the link is unknown
[ "Return", "the", "Link", "or", "raise", "a", "404", "if", "the", "link", "is", "unknown" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L576-L583
train
GNS3/gns3-server
gns3server/controller/project.py
Project.get_snapshot
def get_snapshot(self, snapshot_id): """ Return the snapshot or raise a 404 if the snapshot is unknown """ try: return self._snapshots[snapshot_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Snapshot ID {} doesn't exist".format(snapshot_id))
python
def get_snapshot(self, snapshot_id): """ Return the snapshot or raise a 404 if the snapshot is unknown """ try: return self._snapshots[snapshot_id] except KeyError: raise aiohttp.web.HTTPNotFound(text="Snapshot ID {} doesn't exist".format(snapshot_id))
[ "def", "get_snapshot", "(", "self", ",", "snapshot_id", ")", ":", "try", ":", "return", "self", ".", "_snapshots", "[", "snapshot_id", "]", "except", "KeyError", ":", "raise", "aiohttp", ".", "web", ".", "HTTPNotFound", "(", "text", "=", "\"Snapshot ID {} do...
Return the snapshot or raise a 404 if the snapshot is unknown
[ "Return", "the", "snapshot", "or", "raise", "a", "404", "if", "the", "snapshot", "is", "unknown" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L600-L607
train
GNS3/gns3-server
gns3server/controller/project.py
Project.snapshot
def snapshot(self, name): """ Snapshot the project :param name: Name of the snapshot """ if name in [snap.name for snap in self.snapshots.values()]: raise aiohttp.web_exceptions.HTTPConflict(text="The snapshot {} already exist".format(name)) snapshot = Snap...
python
def snapshot(self, name): """ Snapshot the project :param name: Name of the snapshot """ if name in [snap.name for snap in self.snapshots.values()]: raise aiohttp.web_exceptions.HTTPConflict(text="The snapshot {} already exist".format(name)) snapshot = Snap...
[ "def", "snapshot", "(", "self", ",", "name", ")", ":", "if", "name", "in", "[", "snap", ".", "name", "for", "snap", "in", "self", ".", "snapshots", ".", "values", "(", ")", "]", ":", "raise", "aiohttp", ".", "web_exceptions", ".", "HTTPConflict", "("...
Snapshot the project :param name: Name of the snapshot
[ "Snapshot", "the", "project" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L611-L640
train
GNS3/gns3-server
gns3server/controller/project.py
Project._cleanPictures
def _cleanPictures(self): """ Delete unused images """ # Project have been deleted if not os.path.exists(self.path): return try: pictures = set(os.listdir(self.pictures_directory)) for drawing in self._drawings.values(): ...
python
def _cleanPictures(self): """ Delete unused images """ # Project have been deleted if not os.path.exists(self.path): return try: pictures = set(os.listdir(self.pictures_directory)) for drawing in self._drawings.values(): ...
[ "def", "_cleanPictures", "(", "self", ")", ":", "# Project have been deleted", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", ":", "return", "try", ":", "pictures", "=", "set", "(", "os", ".", "listdir", "(", "self", ".",...
Delete unused images
[ "Delete", "unused", "images" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L663-L682
train
GNS3/gns3-server
gns3server/controller/project.py
Project.delete_on_computes
def delete_on_computes(self): """ Delete the project on computes but not on controller """ for compute in list(self._project_created_on_compute): if compute.id != "local": yield from compute.delete("/projects/{}".format(self._id)) self._project...
python
def delete_on_computes(self): """ Delete the project on computes but not on controller """ for compute in list(self._project_created_on_compute): if compute.id != "local": yield from compute.delete("/projects/{}".format(self._id)) self._project...
[ "def", "delete_on_computes", "(", "self", ")", ":", "for", "compute", "in", "list", "(", "self", ".", "_project_created_on_compute", ")", ":", "if", "compute", ".", "id", "!=", "\"local\"", ":", "yield", "from", "compute", ".", "delete", "(", "\"/projects/{}...
Delete the project on computes but not on controller
[ "Delete", "the", "project", "on", "computes", "but", "not", "on", "controller" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L701-L708
train
GNS3/gns3-server
gns3server/controller/project.py
Project.duplicate
def duplicate(self, name=None, location=None): """ Duplicate a project It's the save as feature of the 1.X. It's implemented on top of the export / import features. It will generate a gns3p and reimport it. It's a little slower but we have only one implementation to maintain. ...
python
def duplicate(self, name=None, location=None): """ Duplicate a project It's the save as feature of the 1.X. It's implemented on top of the export / import features. It will generate a gns3p and reimport it. It's a little slower but we have only one implementation to maintain. ...
[ "def", "duplicate", "(", "self", ",", "name", "=", "None", ",", "location", "=", "None", ")", ":", "# If the project was not open we open it temporary", "previous_status", "=", "self", ".", "_status", "if", "self", ".", "_status", "==", "\"closed\"", ":", "yield...
Duplicate a project It's the save as feature of the 1.X. It's implemented on top of the export / import features. It will generate a gns3p and reimport it. It's a little slower but we have only one implementation to maintain. :param name: Name of the new project. A new one will be gene...
[ "Duplicate", "a", "project" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L844-L875
train
GNS3/gns3-server
gns3server/controller/project.py
Project.is_running
def is_running(self): """ If a node is started or paused return True """ for node in self._nodes.values(): # Some node type are always running we ignore them if node.status != "stopped" and not node.is_always_running(): return True return F...
python
def is_running(self): """ If a node is started or paused return True """ for node in self._nodes.values(): # Some node type are always running we ignore them if node.status != "stopped" and not node.is_always_running(): return True return F...
[ "def", "is_running", "(", "self", ")", ":", "for", "node", "in", "self", ".", "_nodes", ".", "values", "(", ")", ":", "# Some node type are always running we ignore them", "if", "node", ".", "status", "!=", "\"stopped\"", "and", "not", "node", ".", "is_always_...
If a node is started or paused return True
[ "If", "a", "node", "is", "started", "or", "paused", "return", "True" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L877-L885
train
GNS3/gns3-server
gns3server/controller/project.py
Project.dump
def dump(self): """ Dump topology to disk """ try: topo = project_to_topology(self) path = self._topology_file() log.debug("Write %s", path) with open(path + ".tmp", "w+", encoding="utf-8") as f: json.dump(topo, f, indent=4,...
python
def dump(self): """ Dump topology to disk """ try: topo = project_to_topology(self) path = self._topology_file() log.debug("Write %s", path) with open(path + ".tmp", "w+", encoding="utf-8") as f: json.dump(topo, f, indent=4,...
[ "def", "dump", "(", "self", ")", ":", "try", ":", "topo", "=", "project_to_topology", "(", "self", ")", "path", "=", "self", ".", "_topology_file", "(", ")", "log", ".", "debug", "(", "\"Write %s\"", ",", "path", ")", "with", "open", "(", "path", "+"...
Dump topology to disk
[ "Dump", "topology", "to", "disk" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L887-L899
train
GNS3/gns3-server
gns3server/controller/project.py
Project.start_all
def start_all(self): """ Start all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.start) yield from pool.join()
python
def start_all(self): """ Start all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.start) yield from pool.join()
[ "def", "start_all", "(", "self", ")", ":", "pool", "=", "Pool", "(", "concurrency", "=", "3", ")", "for", "node", "in", "self", ".", "nodes", ".", "values", "(", ")", ":", "pool", ".", "append", "(", "node", ".", "start", ")", "yield", "from", "p...
Start all nodes
[ "Start", "all", "nodes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L902-L909
train
GNS3/gns3-server
gns3server/controller/project.py
Project.stop_all
def stop_all(self): """ Stop all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.stop) yield from pool.join()
python
def stop_all(self): """ Stop all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.stop) yield from pool.join()
[ "def", "stop_all", "(", "self", ")", ":", "pool", "=", "Pool", "(", "concurrency", "=", "3", ")", "for", "node", "in", "self", ".", "nodes", ".", "values", "(", ")", ":", "pool", ".", "append", "(", "node", ".", "stop", ")", "yield", "from", "poo...
Stop all nodes
[ "Stop", "all", "nodes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L912-L919
train
GNS3/gns3-server
gns3server/controller/project.py
Project.suspend_all
def suspend_all(self): """ Suspend all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.suspend) yield from pool.join()
python
def suspend_all(self): """ Suspend all nodes """ pool = Pool(concurrency=3) for node in self.nodes.values(): pool.append(node.suspend) yield from pool.join()
[ "def", "suspend_all", "(", "self", ")", ":", "pool", "=", "Pool", "(", "concurrency", "=", "3", ")", "for", "node", "in", "self", ".", "nodes", ".", "values", "(", ")", ":", "pool", ".", "append", "(", "node", ".", "suspend", ")", "yield", "from", ...
Suspend all nodes
[ "Suspend", "all", "nodes" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L922-L929
train
GNS3/gns3-server
gns3server/utils/asyncio/input_stream.py
InputStream._get_match
def _get_match(self, prefix): """ Return the key that maps to this prefix. """ # (hard coded) If we match a CPR response, return Keys.CPRResponse. # (This one doesn't fit in the ANSI_SEQUENCES, because it contains # integer variables.) if _cpr_response_re.match(pr...
python
def _get_match(self, prefix): """ Return the key that maps to this prefix. """ # (hard coded) If we match a CPR response, return Keys.CPRResponse. # (This one doesn't fit in the ANSI_SEQUENCES, because it contains # integer variables.) if _cpr_response_re.match(pr...
[ "def", "_get_match", "(", "self", ",", "prefix", ")", ":", "# (hard coded) If we match a CPR response, return Keys.CPRResponse.", "# (This one doesn't fit in the ANSI_SEQUENCES, because it contains", "# integer variables.)", "if", "_cpr_response_re", ".", "match", "(", "prefix", ")...
Return the key that maps to this prefix.
[ "Return", "the", "key", "that", "maps", "to", "this", "prefix", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L259-L276
train
GNS3/gns3-server
gns3server/utils/asyncio/input_stream.py
InputStream._call_handler
def _call_handler(self, key, insert_text): """ Callback to handler. """ if isinstance(key, tuple): for k in key: self._call_handler(k, insert_text) else: if key == Keys.BracketedPaste: self._in_bracketed_paste = True ...
python
def _call_handler(self, key, insert_text): """ Callback to handler. """ if isinstance(key, tuple): for k in key: self._call_handler(k, insert_text) else: if key == Keys.BracketedPaste: self._in_bracketed_paste = True ...
[ "def", "_call_handler", "(", "self", ",", "key", ",", "insert_text", ")", ":", "if", "isinstance", "(", "key", ",", "tuple", ")", ":", "for", "k", "in", "key", ":", "self", ".", "_call_handler", "(", "k", ",", "insert_text", ")", "else", ":", "if", ...
Callback to handler.
[ "Callback", "to", "handler", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L328-L340
train
GNS3/gns3-server
gns3server/utils/asyncio/input_stream.py
InputStream.feed
def feed(self, data): """ Feed the input stream. :param data: Input string (unicode). """ assert isinstance(data, six.text_type) if _DEBUG_RENDERER_INPUT: self.LOG.write(repr(data).encode('utf-8') + b'\n') self.LOG.flush() # Handle brack...
python
def feed(self, data): """ Feed the input stream. :param data: Input string (unicode). """ assert isinstance(data, six.text_type) if _DEBUG_RENDERER_INPUT: self.LOG.write(repr(data).encode('utf-8') + b'\n') self.LOG.flush() # Handle brack...
[ "def", "feed", "(", "self", ",", "data", ")", ":", "assert", "isinstance", "(", "data", ",", "six", ".", "text_type", ")", "if", "_DEBUG_RENDERER_INPUT", ":", "self", ".", "LOG", ".", "write", "(", "repr", "(", "data", ")", ".", "encode", "(", "'utf-...
Feed the input stream. :param data: Input string (unicode).
[ "Feed", "the", "input", "stream", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/utils/asyncio/input_stream.py#L342-L398
train
GNS3/gns3-server
gns3server/compute/docker/__init__.py
Docker.query
def query(self, method, path, data={}, params={}): """ Make a query to the docker daemon and decode the request :param method: HTTP method :param path: Endpoint in API :param data: Dictionary with the body. Will be transformed to a JSON :param params: Parameters added as...
python
def query(self, method, path, data={}, params={}): """ Make a query to the docker daemon and decode the request :param method: HTTP method :param path: Endpoint in API :param data: Dictionary with the body. Will be transformed to a JSON :param params: Parameters added as...
[ "def", "query", "(", "self", ",", "method", ",", "path", ",", "data", "=", "{", "}", ",", "params", "=", "{", "}", ")", ":", "response", "=", "yield", "from", "self", ".", "http_query", "(", "method", ",", "path", ",", "data", "=", "data", ",", ...
Make a query to the docker daemon and decode the request :param method: HTTP method :param path: Endpoint in API :param data: Dictionary with the body. Will be transformed to a JSON :param params: Parameters added as a query arg
[ "Make", "a", "query", "to", "the", "docker", "daemon", "and", "decode", "the", "request" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L96-L114
train
GNS3/gns3-server
gns3server/compute/docker/__init__.py
Docker.http_query
def http_query(self, method, path, data={}, params={}, timeout=300): """ Make a query to the docker daemon :param method: HTTP method :param path: Endpoint in API :param data: Dictionnary with the body. Will be transformed to a JSON :param params: Parameters added as a q...
python
def http_query(self, method, path, data={}, params={}, timeout=300): """ Make a query to the docker daemon :param method: HTTP method :param path: Endpoint in API :param data: Dictionnary with the body. Will be transformed to a JSON :param params: Parameters added as a q...
[ "def", "http_query", "(", "self", ",", "method", ",", "path", ",", "data", "=", "{", "}", ",", "params", "=", "{", "}", ",", "timeout", "=", "300", ")", ":", "data", "=", "json", ".", "dumps", "(", "data", ")", "if", "timeout", "is", "None", ":...
Make a query to the docker daemon :param method: HTTP method :param path: Endpoint in API :param data: Dictionnary with the body. Will be transformed to a JSON :param params: Parameters added as a query arg :param timeout: Timeout :returns: HTTP response
[ "Make", "a", "query", "to", "the", "docker", "daemon" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L117-L167
train
GNS3/gns3-server
gns3server/compute/docker/__init__.py
Docker.websocket_query
def websocket_query(self, path, params={}): """ Open a websocket connection :param path: Endpoint in API :param params: Parameters added as a query arg :returns: Websocket """ url = "http://docker/v" + self._api_version + "/" + path connection = yield fr...
python
def websocket_query(self, path, params={}): """ Open a websocket connection :param path: Endpoint in API :param params: Parameters added as a query arg :returns: Websocket """ url = "http://docker/v" + self._api_version + "/" + path connection = yield fr...
[ "def", "websocket_query", "(", "self", ",", "path", ",", "params", "=", "{", "}", ")", ":", "url", "=", "\"http://docker/v\"", "+", "self", ".", "_api_version", "+", "\"/\"", "+", "path", "connection", "=", "yield", "from", "self", ".", "_session", ".", ...
Open a websocket connection :param path: Endpoint in API :param params: Parameters added as a query arg :returns: Websocket
[ "Open", "a", "websocket", "connection" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L170-L183
train
GNS3/gns3-server
gns3server/compute/docker/__init__.py
Docker.list_images
def list_images(self): """Gets Docker image list. :returns: list of dicts :rtype: list """ images = [] for image in (yield from self.query("GET", "images/json", params={"all": 0})): if image['RepoTags']: for tag in image['RepoTags']: ...
python
def list_images(self): """Gets Docker image list. :returns: list of dicts :rtype: list """ images = [] for image in (yield from self.query("GET", "images/json", params={"all": 0})): if image['RepoTags']: for tag in image['RepoTags']: ...
[ "def", "list_images", "(", "self", ")", ":", "images", "=", "[", "]", "for", "image", "in", "(", "yield", "from", "self", ".", "query", "(", "\"GET\"", ",", "\"images/json\"", ",", "params", "=", "{", "\"all\"", ":", "0", "}", ")", ")", ":", "if", ...
Gets Docker image list. :returns: list of dicts :rtype: list
[ "Gets", "Docker", "image", "list", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/docker/__init__.py#L228-L240
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.get_kvm_archs
def get_kvm_archs(): """ Gets a list of architectures for which KVM is available on this server. :returns: List of architectures for which KVM is available on this server. """ kvm = [] if not os.path.exists("/dev/kvm"): return kvm arch = platform.ma...
python
def get_kvm_archs(): """ Gets a list of architectures for which KVM is available on this server. :returns: List of architectures for which KVM is available on this server. """ kvm = [] if not os.path.exists("/dev/kvm"): return kvm arch = platform.ma...
[ "def", "get_kvm_archs", "(", ")", ":", "kvm", "=", "[", "]", "if", "not", "os", ".", "path", ".", "exists", "(", "\"/dev/kvm\"", ")", ":", "return", "kvm", "arch", "=", "platform", ".", "machine", "(", ")", "if", "arch", "==", "\"x86_64\"", ":", "k...
Gets a list of architectures for which KVM is available on this server. :returns: List of architectures for which KVM is available on this server.
[ "Gets", "a", "list", "of", "architectures", "for", "which", "KVM", "is", "available", "on", "this", "server", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L45-L64
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.paths_list
def paths_list(): """ Gets a folder list of possibly available QEMU binaries on the host. :returns: List of folders where Qemu binaries MAY reside. """ paths = set() try: paths.add(os.getcwd()) except FileNotFoundError: log.warning("The c...
python
def paths_list(): """ Gets a folder list of possibly available QEMU binaries on the host. :returns: List of folders where Qemu binaries MAY reside. """ paths = set() try: paths.add(os.getcwd()) except FileNotFoundError: log.warning("The c...
[ "def", "paths_list", "(", ")", ":", "paths", "=", "set", "(", ")", "try", ":", "paths", ".", "add", "(", "os", ".", "getcwd", "(", ")", ")", "except", "FileNotFoundError", ":", "log", ".", "warning", "(", "\"The current working directory doesn't exist\"", ...
Gets a folder list of possibly available QEMU binaries on the host. :returns: List of folders where Qemu binaries MAY reside.
[ "Gets", "a", "folder", "list", "of", "possibly", "available", "QEMU", "binaries", "on", "the", "host", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L67-L107
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.binary_list
def binary_list(archs=None): """ Gets QEMU binaries list available on the host. :returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu} """ qemus = [] for path in Qemu.paths_list(): try: for f in os.listdir(path):...
python
def binary_list(archs=None): """ Gets QEMU binaries list available on the host. :returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu} """ qemus = [] for path in Qemu.paths_list(): try: for f in os.listdir(path):...
[ "def", "binary_list", "(", "archs", "=", "None", ")", ":", "qemus", "=", "[", "]", "for", "path", "in", "Qemu", ".", "paths_list", "(", ")", ":", "try", ":", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "if", "f", ".", "endswi...
Gets QEMU binaries list available on the host. :returns: Array of dictionary {"path": Qemu binary path, "version": version of Qemu}
[ "Gets", "QEMU", "binaries", "list", "available", "on", "the", "host", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L110-L140
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.img_binary_list
def img_binary_list(): """ Gets QEMU-img binaries list available on the host. :returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img} """ qemu_imgs = [] for path in Qemu.paths_list(): try: for f in os.listd...
python
def img_binary_list(): """ Gets QEMU-img binaries list available on the host. :returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img} """ qemu_imgs = [] for path in Qemu.paths_list(): try: for f in os.listd...
[ "def", "img_binary_list", "(", ")", ":", "qemu_imgs", "=", "[", "]", "for", "path", "in", "Qemu", ".", "paths_list", "(", ")", ":", "try", ":", "for", "f", "in", "os", ".", "listdir", "(", "path", ")", ":", "if", "(", "f", "==", "\"qemu-img\"", "...
Gets QEMU-img binaries list available on the host. :returns: Array of dictionary {"path": Qemu-img binary path, "version": version of Qemu-img}
[ "Gets", "QEMU", "-", "img", "binaries", "list", "available", "on", "the", "host", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L143-L162
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.get_qemu_version
def get_qemu_version(qemu_path): """ Gets the Qemu version. :param qemu_path: path to Qemu executable. """ if sys.platform.startswith("win"): # Qemu on Windows doesn't return anything with parameter -version # look for a version number in version.txt fil...
python
def get_qemu_version(qemu_path): """ Gets the Qemu version. :param qemu_path: path to Qemu executable. """ if sys.platform.startswith("win"): # Qemu on Windows doesn't return anything with parameter -version # look for a version number in version.txt fil...
[ "def", "get_qemu_version", "(", "qemu_path", ")", ":", "if", "sys", ".", "platform", ".", "startswith", "(", "\"win\"", ")", ":", "# Qemu on Windows doesn't return anything with parameter -version", "# look for a version number in version.txt file in the same directory instead", ...
Gets the Qemu version. :param qemu_path: path to Qemu executable.
[ "Gets", "the", "Qemu", "version", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L166-L197
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu._get_qemu_img_version
def _get_qemu_img_version(qemu_img_path): """ Gets the Qemu-img version. :param qemu_img_path: path to Qemu-img executable. """ try: output = yield from subprocess_check_output(qemu_img_path, "--version") match = re.search("version\s+([0-9a-z\-\.]+)", ou...
python
def _get_qemu_img_version(qemu_img_path): """ Gets the Qemu-img version. :param qemu_img_path: path to Qemu-img executable. """ try: output = yield from subprocess_check_output(qemu_img_path, "--version") match = re.search("version\s+([0-9a-z\-\.]+)", ou...
[ "def", "_get_qemu_img_version", "(", "qemu_img_path", ")", ":", "try", ":", "output", "=", "yield", "from", "subprocess_check_output", "(", "qemu_img_path", ",", "\"--version\"", ")", "match", "=", "re", ".", "search", "(", "\"version\\s+([0-9a-z\\-\\.]+)\"", ",", ...
Gets the Qemu-img version. :param qemu_img_path: path to Qemu-img executable.
[ "Gets", "the", "Qemu", "-", "img", "version", "." ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L201-L217
train
GNS3/gns3-server
gns3server/compute/qemu/__init__.py
Qemu.create_disk
def create_disk(self, qemu_img, path, options): """ Create a qemu disk with qemu-img :param qemu_img: qemu-img binary path :param path: Image path :param options: Disk image creation options """ try: img_format = options.pop("format") img...
python
def create_disk(self, qemu_img, path, options): """ Create a qemu disk with qemu-img :param qemu_img: qemu-img binary path :param path: Image path :param options: Disk image creation options """ try: img_format = options.pop("format") img...
[ "def", "create_disk", "(", "self", ",", "qemu_img", ",", "path", ",", "options", ")", ":", "try", ":", "img_format", "=", "options", ".", "pop", "(", "\"format\"", ")", "img_size", "=", "options", ".", "pop", "(", "\"size\"", ")", "if", "not", "os", ...
Create a qemu disk with qemu-img :param qemu_img: qemu-img binary path :param path: Image path :param options: Disk image creation options
[ "Create", "a", "qemu", "disk", "with", "qemu", "-", "img" ]
a221678448fb5d24e977ef562f81d56aacc89ab1
https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/qemu/__init__.py#L233-L267
train
jmcarpenter2/swifter
swifter/swifter.py
_SwifterObject.set_npartitions
def set_npartitions(self, npartitions=None): """ Set the number of partitions to use for dask """ if npartitions is None: self._npartitions = cpu_count() * 2 else: self._npartitions = npartitions return self
python
def set_npartitions(self, npartitions=None): """ Set the number of partitions to use for dask """ if npartitions is None: self._npartitions = cpu_count() * 2 else: self._npartitions = npartitions return self
[ "def", "set_npartitions", "(", "self", ",", "npartitions", "=", "None", ")", ":", "if", "npartitions", "is", "None", ":", "self", ".", "_npartitions", "=", "cpu_count", "(", ")", "*", "2", "else", ":", "self", ".", "_npartitions", "=", "npartitions", "re...
Set the number of partitions to use for dask
[ "Set", "the", "number", "of", "partitions", "to", "use", "for", "dask" ]
ed5fc3235b43f981fa58ac9bc982c8209d4e3df3
https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L39-L47
train
jmcarpenter2/swifter
swifter/swifter.py
_SwifterObject.rolling
def rolling(self, window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None): """ Create a swifter rolling object """ kwds = { "window": window, "min_periods": min_periods, "center": center, "win_type": win_type, ...
python
def rolling(self, window, min_periods=None, center=False, win_type=None, on=None, axis=0, closed=None): """ Create a swifter rolling object """ kwds = { "window": window, "min_periods": min_periods, "center": center, "win_type": win_type, ...
[ "def", "rolling", "(", "self", ",", "window", ",", "min_periods", "=", "None", ",", "center", "=", "False", ",", "win_type", "=", "None", ",", "on", "=", "None", ",", "axis", "=", "0", ",", "closed", "=", "None", ")", ":", "kwds", "=", "{", "\"wi...
Create a swifter rolling object
[ "Create", "a", "swifter", "rolling", "object" ]
ed5fc3235b43f981fa58ac9bc982c8209d4e3df3
https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L78-L91
train
jmcarpenter2/swifter
swifter/swifter.py
Transformation.apply
def apply(self, func, *args, **kwds): """ Apply the function to the transformed swifter object """ # estimate time to pandas apply wrapped = self._wrapped_apply(func, *args, **kwds) n_repeats = 3 timed = timeit.timeit(wrapped, number=n_repeats) samp_proc_e...
python
def apply(self, func, *args, **kwds): """ Apply the function to the transformed swifter object """ # estimate time to pandas apply wrapped = self._wrapped_apply(func, *args, **kwds) n_repeats = 3 timed = timeit.timeit(wrapped, number=n_repeats) samp_proc_e...
[ "def", "apply", "(", "self", ",", "func", ",", "*", "args", ",", "*", "*", "kwds", ")", ":", "# estimate time to pandas apply", "wrapped", "=", "self", ".", "_wrapped_apply", "(", "func", ",", "*", "args", ",", "*", "*", "kwds", ")", "n_repeats", "=", ...
Apply the function to the transformed swifter object
[ "Apply", "the", "function", "to", "the", "transformed", "swifter", "object" ]
ed5fc3235b43f981fa58ac9bc982c8209d4e3df3
https://github.com/jmcarpenter2/swifter/blob/ed5fc3235b43f981fa58ac9bc982c8209d4e3df3/swifter/swifter.py#L338-L357
train
summernote/django-summernote
django_summernote/utils.py
using_config
def using_config(_func=None): """ This allows a function to use Summernote configuration as a global variable, temporarily. """ def decorator(func): @wraps(func) def inner_dec(*args, **kwargs): g = func.__globals__ var_name = 'config' sentinel = ob...
python
def using_config(_func=None): """ This allows a function to use Summernote configuration as a global variable, temporarily. """ def decorator(func): @wraps(func) def inner_dec(*args, **kwargs): g = func.__globals__ var_name = 'config' sentinel = ob...
[ "def", "using_config", "(", "_func", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "inner_dec", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "g", "=", "func", ".", "__globals__", ...
This allows a function to use Summernote configuration as a global variable, temporarily.
[ "This", "allows", "a", "function", "to", "use", "Summernote", "configuration", "as", "a", "global", "variable", "temporarily", "." ]
bc7fbbf065d88a909fe3e1533c84110e0dd132bc
https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L117-L146
train
summernote/django-summernote
django_summernote/utils.py
uploaded_filepath
def uploaded_filepath(instance, filename): """ Returns default filepath for uploaded files. """ ext = filename.split('.')[-1] filename = "%s.%s" % (uuid.uuid4(), ext) today = datetime.now().strftime('%Y-%m-%d') return os.path.join('django-summernote', today, filename)
python
def uploaded_filepath(instance, filename): """ Returns default filepath for uploaded files. """ ext = filename.split('.')[-1] filename = "%s.%s" % (uuid.uuid4(), ext) today = datetime.now().strftime('%Y-%m-%d') return os.path.join('django-summernote', today, filename)
[ "def", "uploaded_filepath", "(", "instance", ",", "filename", ")", ":", "ext", "=", "filename", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "filename", "=", "\"%s.%s\"", "%", "(", "uuid", ".", "uuid4", "(", ")", ",", "ext", ")", "today", "="...
Returns default filepath for uploaded files.
[ "Returns", "default", "filepath", "for", "uploaded", "files", "." ]
bc7fbbf065d88a909fe3e1533c84110e0dd132bc
https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L149-L156
train
summernote/django-summernote
django_summernote/utils.py
get_attachment_model
def get_attachment_model(): """ Returns the Attachment model that is active in this project. """ try: from .models import AbstractAttachment klass = apps.get_model(config["attachment_model"]) if not issubclass(klass, AbstractAttachment): raise ImproperlyConfigured( ...
python
def get_attachment_model(): """ Returns the Attachment model that is active in this project. """ try: from .models import AbstractAttachment klass = apps.get_model(config["attachment_model"]) if not issubclass(klass, AbstractAttachment): raise ImproperlyConfigured( ...
[ "def", "get_attachment_model", "(", ")", ":", "try", ":", "from", ".", "models", "import", "AbstractAttachment", "klass", "=", "apps", ".", "get_model", "(", "config", "[", "\"attachment_model\"", "]", ")", "if", "not", "issubclass", "(", "klass", ",", "Abst...
Returns the Attachment model that is active in this project.
[ "Returns", "the", "Attachment", "model", "that", "is", "active", "in", "this", "project", "." ]
bc7fbbf065d88a909fe3e1533c84110e0dd132bc
https://github.com/summernote/django-summernote/blob/bc7fbbf065d88a909fe3e1533c84110e0dd132bc/django_summernote/utils.py#L180-L199
train
PyMySQL/mysqlclient-python
MySQLdb/connections.py
numeric_part
def numeric_part(s): """Returns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16 """ m = re_numeric_part.match(s) if m: return int(m.group(1)) return None
python
def numeric_part(s): """Returns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16 """ m = re_numeric_part.match(s) if m: return int(m.group(1)) return None
[ "def", "numeric_part", "(", "s", ")", ":", "m", "=", "re_numeric_part", ".", "match", "(", "s", ")", "if", "m", ":", "return", "int", "(", "m", ".", "group", "(", "1", ")", ")", "return", "None" ]
Returns the leading numeric part of a string. >>> numeric_part("20-alpha") 20 >>> numeric_part("foo") >>> numeric_part("16b") 16
[ "Returns", "the", "leading", "numeric", "part", "of", "a", "string", "." ]
b66971ee36be96b772ae7fdec79ccc1611376f3c
https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L21-L34
train
PyMySQL/mysqlclient-python
MySQLdb/connections.py
Connection.literal
def literal(self, o): """If o is a single object, returns an SQL literal as a string. If o is a non-string sequence, the items of the sequence are converted and returned as a sequence. Non-standard. For internal use; do not use this in your applications. """ if i...
python
def literal(self, o): """If o is a single object, returns an SQL literal as a string. If o is a non-string sequence, the items of the sequence are converted and returned as a sequence. Non-standard. For internal use; do not use this in your applications. """ if i...
[ "def", "literal", "(", "self", ",", "o", ")", ":", "if", "isinstance", "(", "o", ",", "unicode", ")", ":", "s", "=", "self", ".", "string_literal", "(", "o", ".", "encode", "(", "self", ".", "encoding", ")", ")", "elif", "isinstance", "(", "o", "...
If o is a single object, returns an SQL literal as a string. If o is a non-string sequence, the items of the sequence are converted and returned as a sequence. Non-standard. For internal use; do not use this in your applications.
[ "If", "o", "is", "a", "single", "object", "returns", "an", "SQL", "literal", "as", "a", "string", ".", "If", "o", "is", "a", "non", "-", "string", "sequence", "the", "items", "of", "the", "sequence", "are", "converted", "and", "returned", "as", "a", ...
b66971ee36be96b772ae7fdec79ccc1611376f3c
https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L238-L262
train
PyMySQL/mysqlclient-python
MySQLdb/connections.py
Connection.set_character_set
def set_character_set(self, charset): """Set the connection character set to charset. The character set can only be changed in MySQL-4.1 and newer. If you try to change the character set from the current value in an older version, NotSupportedError will be raised.""" if charset i...
python
def set_character_set(self, charset): """Set the connection character set to charset. The character set can only be changed in MySQL-4.1 and newer. If you try to change the character set from the current value in an older version, NotSupportedError will be raised.""" if charset i...
[ "def", "set_character_set", "(", "self", ",", "charset", ")", ":", "if", "charset", "in", "(", "\"utf8mb4\"", ",", "\"utf8mb3\"", ")", ":", "py_charset", "=", "\"utf8\"", "else", ":", "py_charset", "=", "charset", "if", "self", ".", "character_set_name", "("...
Set the connection character set to charset. The character set can only be changed in MySQL-4.1 and newer. If you try to change the character set from the current value in an older version, NotSupportedError will be raised.
[ "Set", "the", "connection", "character", "set", "to", "charset", ".", "The", "character", "set", "can", "only", "be", "changed", "in", "MySQL", "-", "4", ".", "1", "and", "newer", ".", "If", "you", "try", "to", "change", "the", "character", "set", "fro...
b66971ee36be96b772ae7fdec79ccc1611376f3c
https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L282-L299
train
PyMySQL/mysqlclient-python
MySQLdb/connections.py
Connection.set_sql_mode
def set_sql_mode(self, sql_mode): """Set the connection sql_mode. See MySQL documentation for legal values.""" if self._server_version < (4, 1): raise NotSupportedError("server is too old to set sql_mode") self.query("SET SESSION sql_mode='%s'" % sql_mode) self.store_...
python
def set_sql_mode(self, sql_mode): """Set the connection sql_mode. See MySQL documentation for legal values.""" if self._server_version < (4, 1): raise NotSupportedError("server is too old to set sql_mode") self.query("SET SESSION sql_mode='%s'" % sql_mode) self.store_...
[ "def", "set_sql_mode", "(", "self", ",", "sql_mode", ")", ":", "if", "self", ".", "_server_version", "<", "(", "4", ",", "1", ")", ":", "raise", "NotSupportedError", "(", "\"server is too old to set sql_mode\"", ")", "self", ".", "query", "(", "\"SET SESSION s...
Set the connection sql_mode. See MySQL documentation for legal values.
[ "Set", "the", "connection", "sql_mode", ".", "See", "MySQL", "documentation", "for", "legal", "values", "." ]
b66971ee36be96b772ae7fdec79ccc1611376f3c
https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/connections.py#L301-L307
train
PyMySQL/mysqlclient-python
MySQLdb/cursors.py
BaseCursor.close
def close(self): """Close the cursor. No further queries will be possible.""" try: if self.connection is None: return while self.nextset(): pass finally: self.connection = None self._result = None
python
def close(self): """Close the cursor. No further queries will be possible.""" try: if self.connection is None: return while self.nextset(): pass finally: self.connection = None self._result = None
[ "def", "close", "(", "self", ")", ":", "try", ":", "if", "self", ".", "connection", "is", "None", ":", "return", "while", "self", ".", "nextset", "(", ")", ":", "pass", "finally", ":", "self", ".", "connection", "=", "None", "self", ".", "_result", ...
Close the cursor. No further queries will be possible.
[ "Close", "the", "cursor", ".", "No", "further", "queries", "will", "be", "possible", "." ]
b66971ee36be96b772ae7fdec79ccc1611376f3c
https://github.com/PyMySQL/mysqlclient-python/blob/b66971ee36be96b772ae7fdec79ccc1611376f3c/MySQLdb/cursors.py#L81-L90
train
MagicStack/asyncpg
asyncpg/cursor.py
Cursor.fetchrow
async def fetchrow(self, *, timeout=None): r"""Return the next row. :param float timeout: Optional timeout value in seconds. :return: A :class:`Record` instance. """ self._check_ready() if self._exhausted: return None recs = await self._exec(1, timeo...
python
async def fetchrow(self, *, timeout=None): r"""Return the next row. :param float timeout: Optional timeout value in seconds. :return: A :class:`Record` instance. """ self._check_ready() if self._exhausted: return None recs = await self._exec(1, timeo...
[ "async", "def", "fetchrow", "(", "self", ",", "*", ",", "timeout", "=", "None", ")", ":", "self", ".", "_check_ready", "(", ")", "if", "self", ".", "_exhausted", ":", "return", "None", "recs", "=", "await", "self", ".", "_exec", "(", "1", ",", "tim...
r"""Return the next row. :param float timeout: Optional timeout value in seconds. :return: A :class:`Record` instance.
[ "r", "Return", "the", "next", "row", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cursor.py#L224-L238
train
MagicStack/asyncpg
asyncpg/connresource.py
guarded
def guarded(meth): """A decorator to add a sanity check to ConnectionResource methods.""" @functools.wraps(meth) def _check(self, *args, **kwargs): self._check_conn_validity(meth.__name__) return meth(self, *args, **kwargs) return _check
python
def guarded(meth): """A decorator to add a sanity check to ConnectionResource methods.""" @functools.wraps(meth) def _check(self, *args, **kwargs): self._check_conn_validity(meth.__name__) return meth(self, *args, **kwargs) return _check
[ "def", "guarded", "(", "meth", ")", ":", "@", "functools", ".", "wraps", "(", "meth", ")", "def", "_check", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_conn_validity", "(", "meth", ".", "__name__", ")", "r...
A decorator to add a sanity check to ConnectionResource methods.
[ "A", "decorator", "to", "add", "a", "sanity", "check", "to", "ConnectionResource", "methods", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connresource.py#L14-L22
train
MagicStack/asyncpg
asyncpg/cluster.py
Cluster.start
def start(self, wait=60, *, server_settings={}, **opts): """Start the cluster.""" status = self.get_status() if status == 'running': return elif status == 'not-initialized': raise ClusterError( 'cluster in {!r} has not been initialized'.format( ...
python
def start(self, wait=60, *, server_settings={}, **opts): """Start the cluster.""" status = self.get_status() if status == 'running': return elif status == 'not-initialized': raise ClusterError( 'cluster in {!r} has not been initialized'.format( ...
[ "def", "start", "(", "self", ",", "wait", "=", "60", ",", "*", ",", "server_settings", "=", "{", "}", ",", "*", "*", "opts", ")", ":", "status", "=", "self", ".", "get_status", "(", ")", "if", "status", "==", "'running'", ":", "return", "elif", "...
Start the cluster.
[ "Start", "the", "cluster", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L144-L222
train
MagicStack/asyncpg
asyncpg/cluster.py
Cluster.reload
def reload(self): """Reload server configuration.""" status = self.get_status() if status != 'running': raise ClusterError('cannot reload: cluster is not running') process = subprocess.run( [self._pg_ctl, 'reload', '-D', self._data_dir], stdout=subpro...
python
def reload(self): """Reload server configuration.""" status = self.get_status() if status != 'running': raise ClusterError('cannot reload: cluster is not running') process = subprocess.run( [self._pg_ctl, 'reload', '-D', self._data_dir], stdout=subpro...
[ "def", "reload", "(", "self", ")", ":", "status", "=", "self", ".", "get_status", "(", ")", "if", "status", "!=", "'running'", ":", "raise", "ClusterError", "(", "'cannot reload: cluster is not running'", ")", "process", "=", "subprocess", ".", "run", "(", "...
Reload server configuration.
[ "Reload", "server", "configuration", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L224-L239
train
MagicStack/asyncpg
asyncpg/cluster.py
Cluster.reset_hba
def reset_hba(self): """Remove all records from pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: cluster is not initialized') pg_hba = os.path.join(self._data_dir, 'pg_hba.conf') ...
python
def reset_hba(self): """Remove all records from pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: cluster is not initialized') pg_hba = os.path.join(self._data_dir, 'pg_hba.conf') ...
[ "def", "reset_hba", "(", "self", ")", ":", "status", "=", "self", ".", "get_status", "(", ")", "if", "status", "==", "'not-initialized'", ":", "raise", "ClusterError", "(", "'cannot modify HBA records: cluster is not initialized'", ")", "pg_hba", "=", "os", ".", ...
Remove all records from pg_hba.conf.
[ "Remove", "all", "records", "from", "pg_hba", ".", "conf", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L323-L337
train
MagicStack/asyncpg
asyncpg/cluster.py
Cluster.add_hba_entry
def add_hba_entry(self, *, type='host', database, user, address=None, auth_method, auth_options=None): """Add a record to pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: c...
python
def add_hba_entry(self, *, type='host', database, user, address=None, auth_method, auth_options=None): """Add a record to pg_hba.conf.""" status = self.get_status() if status == 'not-initialized': raise ClusterError( 'cannot modify HBA records: c...
[ "def", "add_hba_entry", "(", "self", ",", "*", ",", "type", "=", "'host'", ",", "database", ",", "user", ",", "address", "=", "None", ",", "auth_method", ",", "auth_options", "=", "None", ")", ":", "status", "=", "self", ".", "get_status", "(", ")", ...
Add a record to pg_hba.conf.
[ "Add", "a", "record", "to", "pg_hba", ".", "conf", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/cluster.py#L339-L372
train
MagicStack/asyncpg
asyncpg/connection.py
connect
async def connect(dsn=None, *, host=None, port=None, user=None, password=None, passfile=None, database=None, loop=None, timeout=60, statement_cache_size=100, max_cached_statement_lifetime=300, ...
python
async def connect(dsn=None, *, host=None, port=None, user=None, password=None, passfile=None, database=None, loop=None, timeout=60, statement_cache_size=100, max_cached_statement_lifetime=300, ...
[ "async", "def", "connect", "(", "dsn", "=", "None", ",", "*", ",", "host", "=", "None", ",", "port", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "passfile", "=", "None", ",", "database", "=", "None", ",", "loop", "="...
r"""A coroutine to establish a connection to a PostgreSQL server. The connection parameters may be specified either as a connection URI in *dsn*, or as specific keyword arguments, or both. If both *dsn* and keyword arguments are specified, the latter override the corresponding values parsed from the co...
[ "r", "A", "coroutine", "to", "establish", "a", "connection", "to", "a", "PostgreSQL", "server", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1494-L1688
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.add_listener
async def add_listener(self, channel, callback): """Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with;...
python
async def add_listener(self, channel, callback): """Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with;...
[ "async", "def", "add_listener", "(", "self", ",", "channel", ",", "callback", ")", ":", "self", ".", "_check_open", "(", ")", "if", "channel", "not", "in", "self", ".", "_listeners", ":", "await", "self", ".", "fetch", "(", "'LISTEN {}'", ".", "format", ...
Add a listener for Postgres notifications. :param str channel: Channel to listen on. :param callable callback: A callable receiving the following arguments: **connection**: a Connection the callback is registered with; **pid**: PID of the Postgres server that sent t...
[ "Add", "a", "listener", "for", "Postgres", "notifications", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L126-L142
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.remove_listener
async def remove_listener(self, channel, callback): """Remove a listening callback on the specified channel.""" if self.is_closed(): return if channel not in self._listeners: return if callback not in self._listeners[channel]: return self._list...
python
async def remove_listener(self, channel, callback): """Remove a listening callback on the specified channel.""" if self.is_closed(): return if channel not in self._listeners: return if callback not in self._listeners[channel]: return self._list...
[ "async", "def", "remove_listener", "(", "self", ",", "channel", ",", "callback", ")", ":", "if", "self", ".", "is_closed", "(", ")", ":", "return", "if", "channel", "not", "in", "self", ".", "_listeners", ":", "return", "if", "callback", "not", "in", "...
Remove a listening callback on the specified channel.
[ "Remove", "a", "listening", "callback", "on", "the", "specified", "channel", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L144-L155
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.add_log_listener
def add_log_listener(self, callback): """Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A calla...
python
def add_log_listener(self, callback): """Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A calla...
[ "def", "add_log_listener", "(", "self", ",", "callback", ")", ":", "if", "self", ".", "is_closed", "(", ")", ":", "raise", "exceptions", ".", "InterfaceError", "(", "'connection is closed'", ")", "self", ".", "_log_listeners", ".", "add", "(", "callback", ")...
Add a listener for Postgres log messages. It will be called when asyncronous NoticeResponse is received from the connection. Possible message types are: WARNING, NOTICE, DEBUG, INFO, or LOG. :param callable callback: A callable receiving the following arguments: ...
[ "Add", "a", "listener", "for", "Postgres", "log", "messages", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L157-L173
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_from_table
async def copy_from_table(self, table_name, *, output, columns=None, schema_name=None, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quot...
python
async def copy_from_table(self, table_name, *, output, columns=None, schema_name=None, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quot...
[ "async", "def", "copy_from_table", "(", "self", ",", "table_name", ",", "*", ",", "output", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "delimiter...
Copy table contents to a file or file-like object. :param str table_name: The name of the table to copy data from. :param output: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <python:file-like object>`, or a :term:`c...
[ "Copy", "table", "contents", "to", "a", "file", "or", "file", "-", "like", "object", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L460-L530
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_from_query
async def copy_from_query(self, query, *args, output, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quote=None, encoding=None): "...
python
async def copy_from_query(self, query, *args, output, timeout=None, format=None, oids=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_quote=None, encoding=None): "...
[ "async", "def", "copy_from_query", "(", "self", ",", "query", ",", "*", "args", ",", "output", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "delimiter", "=", "None", ",", "null", "=", "None", ",", "header", ...
Copy the results of a query to a file or file-like object. :param str query: The query to copy the results of. :param args: Query arguments. :param output: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <pytho...
[ "Copy", "the", "results", "of", "a", "query", "to", "a", "file", "or", "file", "-", "like", "object", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L532-L592
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_to_table
async def copy_to_table(self, table_name, *, source, columns=None, schema_name=None, timeout=None, format=None, oids=None, freeze=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_q...
python
async def copy_to_table(self, table_name, *, source, columns=None, schema_name=None, timeout=None, format=None, oids=None, freeze=None, delimiter=None, null=None, header=None, quote=None, escape=None, force_q...
[ "async", "def", "copy_to_table", "(", "self", ",", "table_name", ",", "*", ",", "source", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ",", "format", "=", "None", ",", "oids", "=", "None", ",", "freeze", ...
Copy data to the specified table. :param str table_name: The name of the table to copy data to. :param source: A :term:`path-like object <python:path-like object>`, or a :term:`file-like object <python:file-like object>`, or an :term:`asynchronous iterab...
[ "Copy", "data", "to", "the", "specified", "table", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L594-L667
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.copy_records_to_table
async def copy_records_to_table(self, table_name, *, records, columns=None, schema_name=None, timeout=None): """Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the tab...
python
async def copy_records_to_table(self, table_name, *, records, columns=None, schema_name=None, timeout=None): """Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the tab...
[ "async", "def", "copy_records_to_table", "(", "self", ",", "table_name", ",", "*", ",", "records", ",", "columns", "=", "None", ",", "schema_name", "=", "None", ",", "timeout", "=", "None", ")", ":", "tabname", "=", "utils", ".", "_quote_ident", "(", "ta...
Copy a list of records to the specified table using binary COPY. :param str table_name: The name of the table to copy data to. :param records: An iterable returning row tuples to copy into the table. :param list columns: An optional list of column names to ...
[ "Copy", "a", "list", "of", "records", "to", "the", "specified", "table", "using", "binary", "COPY", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L669-L732
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.set_builtin_type_codec
async def set_builtin_type_codec(self, typename, *, schema='public', codec_name, format=None): """Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec...
python
async def set_builtin_type_codec(self, typename, *, schema='public', codec_name, format=None): """Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec...
[ "async", "def", "set_builtin_type_codec", "(", "self", ",", "typename", ",", "*", ",", "schema", "=", "'public'", ",", "codec_name", ",", "format", "=", "None", ")", ":", "self", ".", "_check_open", "(", ")", "typeinfo", "=", "await", "self", ".", "fetch...
Set a builtin codec for the specified scalar data type. This method has two uses. The first is to register a builtin codec for an extension type without a stable OID, such as 'hstore'. The second use is to declare that an extension type or a user-defined type is wire-compatible with a ...
[ "Set", "a", "builtin", "codec", "for", "the", "specified", "scalar", "data", "type", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1007-L1061
train
MagicStack/asyncpg
asyncpg/connection.py
Connection.close
async def close(self, *, timeout=None): """Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter. """ try: if not self.is_closed(): aw...
python
async def close(self, *, timeout=None): """Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter. """ try: if not self.is_closed(): aw...
[ "async", "def", "close", "(", "self", ",", "*", ",", "timeout", "=", "None", ")", ":", "try", ":", "if", "not", "self", ".", "is_closed", "(", ")", ":", "await", "self", ".", "_protocol", ".", "close", "(", "timeout", ")", "except", "Exception", ":...
Close the connection gracefully. :param float timeout: Optional timeout value in seconds. .. versionchanged:: 0.14.0 Added the *timeout* parameter.
[ "Close", "the", "connection", "gracefully", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connection.py#L1071-L1088
train
MagicStack/asyncpg
asyncpg/pool.py
create_pool
def create_pool(dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=connection.Connection, ...
python
def create_pool(dsn=None, *, min_size=10, max_size=10, max_queries=50000, max_inactive_connection_lifetime=300.0, setup=None, init=None, loop=None, connection_class=connection.Connection, ...
[ "def", "create_pool", "(", "dsn", "=", "None", ",", "*", ",", "min_size", "=", "10", ",", "max_size", "=", "10", ",", "max_queries", "=", "50000", ",", "max_inactive_connection_lifetime", "=", "300.0", ",", "setup", "=", "None", ",", "init", "=", "None",...
r"""Create a connection pool. Can be used either with an ``async with`` block: .. code-block:: python async with asyncpg.create_pool(user='postgres', command_timeout=60) as pool: async with pool.acquire() as con: await con.fetch('SELE...
[ "r", "Create", "a", "connection", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L778-L889
train
MagicStack/asyncpg
asyncpg/pool.py
PoolConnectionHolder._release
def _release(self): """Release this connection holder.""" if self._in_use is None: # The holder is not checked out. return if not self._in_use.done(): self._in_use.set_result(None) self._in_use = None # Deinitialize the connection proxy. All...
python
def _release(self): """Release this connection holder.""" if self._in_use is None: # The holder is not checked out. return if not self._in_use.done(): self._in_use.set_result(None) self._in_use = None # Deinitialize the connection proxy. All...
[ "def", "_release", "(", "self", ")", ":", "if", "self", ".", "_in_use", "is", "None", ":", "# The holder is not checked out.", "return", "if", "not", "self", ".", "_in_use", ".", "done", "(", ")", ":", "self", ".", "_in_use", ".", "set_result", "(", "Non...
Release this connection holder.
[ "Release", "this", "connection", "holder", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L276-L293
train
MagicStack/asyncpg
asyncpg/pool.py
Pool.set_connect_args
def set_connect_args(self, dsn=None, **connect_kwargs): r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() ...
python
def set_connect_args(self, dsn=None, **connect_kwargs): r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() ...
[ "def", "set_connect_args", "(", "self", ",", "dsn", "=", "None", ",", "*", "*", "connect_kwargs", ")", ":", "self", ".", "_connect_args", "=", "[", "dsn", "]", "self", ".", "_connect_kwargs", "=", "connect_kwargs", "self", ".", "_working_addr", "=", "None"...
r"""Set the new connection arguments for this pool. The new connection arguments will be used for all subsequent new connection attempts. Existing connections will remain until they expire. Use :meth:`Pool.expire_connections() <asyncpg.pool.Pool.expire_connections>` to expedite the con...
[ "r", "Set", "the", "new", "connection", "arguments", "for", "this", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L429-L454
train
MagicStack/asyncpg
asyncpg/pool.py
Pool.release
async def release(self, connection, *, timeout=None): """Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not speci...
python
async def release(self, connection, *, timeout=None): """Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not speci...
[ "async", "def", "release", "(", "self", ",", "connection", ",", "*", ",", "timeout", "=", "None", ")", ":", "if", "(", "type", "(", "connection", ")", "is", "not", "PoolConnectionProxy", "or", "connection", ".", "_holder", ".", "_pool", "is", "not", "s...
Release a database connection back to the pool. :param Connection connection: A :class:`~asyncpg.connection.Connection` object to release. :param float timeout: A timeout for releasing the connection. If not specified, defaults to the timeout provided in the corresp...
[ "Release", "a", "database", "connection", "back", "to", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L609-L645
train
MagicStack/asyncpg
asyncpg/pool.py
Pool.close
async def close(self): """Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.termina...
python
async def close(self): """Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.termina...
[ "async", "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_check_init", "(", ")", "self", ".", "_closing", "=", "True", "warning_callback", "=", "None", "try", ":", "warning_callback", "=", "self", ".", ...
Attempt to gracefully close all connections in the pool. Wait until all pool connections are released, close them and shut down the pool. If any error (including cancellation) occurs in ``close()`` the pool will terminate by calling :meth:`Pool.terminate() <pool.Pool.terminate>`. ...
[ "Attempt", "to", "gracefully", "close", "all", "connections", "in", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L647-L690
train
MagicStack/asyncpg
asyncpg/pool.py
Pool.terminate
def terminate(self): """Terminate all connections in the pool.""" if self._closed: return self._check_init() for ch in self._holders: ch.terminate() self._closed = True
python
def terminate(self): """Terminate all connections in the pool.""" if self._closed: return self._check_init() for ch in self._holders: ch.terminate() self._closed = True
[ "def", "terminate", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "self", ".", "_check_init", "(", ")", "for", "ch", "in", "self", ".", "_holders", ":", "ch", ".", "terminate", "(", ")", "self", ".", "_closed", "=", "True" ]
Terminate all connections in the pool.
[ "Terminate", "all", "connections", "in", "the", "pool", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/pool.py#L698-L705
train
MagicStack/asyncpg
asyncpg/transaction.py
Transaction.start
async def start(self): """Enter the transaction or savepoint block.""" self.__check_state_base('start') if self._state is TransactionState.STARTED: raise apg_errors.InterfaceError( 'cannot start; the transaction is already started') con = self._connection ...
python
async def start(self): """Enter the transaction or savepoint block.""" self.__check_state_base('start') if self._state is TransactionState.STARTED: raise apg_errors.InterfaceError( 'cannot start; the transaction is already started') con = self._connection ...
[ "async", "def", "start", "(", "self", ")", ":", "self", ".", "__check_state_base", "(", "'start'", ")", "if", "self", ".", "_state", "is", "TransactionState", ".", "STARTED", ":", "raise", "apg_errors", ".", "InterfaceError", "(", "'cannot start; the transaction...
Enter the transaction or savepoint block.
[ "Enter", "the", "transaction", "or", "savepoint", "block", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/transaction.py#L96-L143
train
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.get_statusmsg
def get_statusmsg(self) -> str: """Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE" """ if self._last_status is None: ...
python
def get_statusmsg(self) -> str: """Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE" """ if self._last_status is None: ...
[ "def", "get_statusmsg", "(", "self", ")", "->", "str", ":", "if", "self", ".", "_last_status", "is", "None", ":", "return", "self", ".", "_last_status", "return", "self", ".", "_last_status", ".", "decode", "(", ")" ]
Return the status of the executed command. Example:: stmt = await connection.prepare('CREATE TABLE mytab (a int)') await stmt.fetch() assert stmt.get_statusmsg() == "CREATE TABLE"
[ "Return", "the", "status", "of", "the", "executed", "command", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L39-L50
train
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.explain
async def explain(self, *args, analyze=False): """Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object repre...
python
async def explain(self, *args, analyze=False): """Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object repre...
[ "async", "def", "explain", "(", "self", ",", "*", "args", ",", "analyze", "=", "False", ")", ":", "query", "=", "'EXPLAIN (FORMAT JSON, VERBOSE'", "if", "analyze", ":", "query", "+=", "', ANALYZE) '", "else", ":", "query", "+=", "') '", "query", "+=", "sel...
Return the execution plan of the statement. :param args: Query arguments. :param analyze: If ``True``, the statement will be executed and the run time statitics added to the return value. :return: An object representing the execution plan. This value i...
[ "Return", "the", "execution", "plan", "of", "the", "statement", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L111-L150
train
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.fetchval
async def fetchval(self, *args, column=0, timeout=None): """Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout...
python
async def fetchval(self, *args, column=0, timeout=None): """Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout...
[ "async", "def", "fetchval", "(", "self", ",", "*", "args", ",", "column", "=", "0", ",", "timeout", "=", "None", ")", ":", "data", "=", "await", "self", ".", "__bind_execute", "(", "args", ",", "1", ",", "timeout", ")", "if", "not", "data", ":", ...
Execute the statement and return a value in the first row. :param args: Query arguments. :param int column: Numeric index within the record of the value to return (defaults to 0). :param float timeout: Optional timeout value in seconds. If ...
[ "Execute", "the", "statement", "and", "return", "a", "value", "in", "the", "first", "row", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L166-L182
train
MagicStack/asyncpg
asyncpg/prepared_stmt.py
PreparedStatement.fetchrow
async def fetchrow(self, *args, timeout=None): """Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance. """...
python
async def fetchrow(self, *args, timeout=None): """Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance. """...
[ "async", "def", "fetchrow", "(", "self", ",", "*", "args", ",", "timeout", "=", "None", ")", ":", "data", "=", "await", "self", ".", "__bind_execute", "(", "args", ",", "1", ",", "timeout", ")", "if", "not", "data", ":", "return", "None", "return", ...
Execute the statement and return the first row. :param str query: Query text :param args: Query arguments :param float timeout: Optional timeout value in seconds. :return: The first row as a :class:`Record` instance.
[ "Execute", "the", "statement", "and", "return", "the", "first", "row", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/prepared_stmt.py#L185-L197
train
MagicStack/asyncpg
asyncpg/connect_utils.py
_read_password_from_pgpass
def _read_password_from_pgpass( *, passfile: typing.Optional[pathlib.Path], hosts: typing.List[str], ports: typing.List[int], database: str, user: str): """Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherw...
python
def _read_password_from_pgpass( *, passfile: typing.Optional[pathlib.Path], hosts: typing.List[str], ports: typing.List[int], database: str, user: str): """Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherw...
[ "def", "_read_password_from_pgpass", "(", "*", ",", "passfile", ":", "typing", ".", "Optional", "[", "pathlib", ".", "Path", "]", ",", "hosts", ":", "typing", ".", "List", "[", "str", "]", ",", "ports", ":", "typing", ".", "List", "[", "int", "]", ",...
Parse the pgpass file and return the matching password. :return: Password string, if found, ``None`` otherwise.
[ "Parse", "the", "pgpass", "file", "and", "return", "the", "matching", "password", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/connect_utils.py#L105-L139
train
MagicStack/asyncpg
asyncpg/utils.py
_mogrify
async def _mogrify(conn, query, args): """Safely inline arguments to query text.""" # Introspect the target query for argument types and # build a list of safely-quoted fully-qualified type names. ps = await conn.prepare(query) paramtypes = [] for t in ps.get_parameters(): if t.name.ends...
python
async def _mogrify(conn, query, args): """Safely inline arguments to query text.""" # Introspect the target query for argument types and # build a list of safely-quoted fully-qualified type names. ps = await conn.prepare(query) paramtypes = [] for t in ps.get_parameters(): if t.name.ends...
[ "async", "def", "_mogrify", "(", "conn", ",", "query", ",", "args", ")", ":", "# Introspect the target query for argument types and", "# build a list of safely-quoted fully-qualified type names.", "ps", "=", "await", "conn", ".", "prepare", "(", "query", ")", "paramtypes"...
Safely inline arguments to query text.
[ "Safely", "inline", "arguments", "to", "query", "text", "." ]
92c2d81256a1efd8cab12c0118d74ccd1c18131b
https://github.com/MagicStack/asyncpg/blob/92c2d81256a1efd8cab12c0118d74ccd1c18131b/asyncpg/utils.py#L19-L45
train
jrfonseca/gprof2dot
gprof2dot.py
Event.aggregate
def aggregate(self, val1, val2): """Aggregate two event values.""" assert val1 is not None assert val2 is not None return self._aggregator(val1, val2)
python
def aggregate(self, val1, val2): """Aggregate two event values.""" assert val1 is not None assert val2 is not None return self._aggregator(val1, val2)
[ "def", "aggregate", "(", "self", ",", "val1", ",", "val2", ")", ":", "assert", "val1", "is", "not", "None", "assert", "val2", "is", "not", "None", "return", "self", ".", "_aggregator", "(", "val1", ",", "val2", ")" ]
Aggregate two event values.
[ "Aggregate", "two", "event", "values", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L121-L125
train
jrfonseca/gprof2dot
gprof2dot.py
Function.stripped_name
def stripped_name(self): """Remove extraneous information from C++ demangled function names.""" name = self.name # Strip function parameters from name by recursively removing paired parenthesis while True: name, n = self._parenthesis_re.subn('', name) if not n: ...
python
def stripped_name(self): """Remove extraneous information from C++ demangled function names.""" name = self.name # Strip function parameters from name by recursively removing paired parenthesis while True: name, n = self._parenthesis_re.subn('', name) if not n: ...
[ "def", "stripped_name", "(", "self", ")", ":", "name", "=", "self", ".", "name", "# Strip function parameters from name by recursively removing paired parenthesis", "while", "True", ":", "name", ",", "n", "=", "self", ".", "_parenthesis_re", ".", "subn", "(", "''", ...
Remove extraneous information from C++ demangled function names.
[ "Remove", "extraneous", "information", "from", "C", "++", "demangled", "function", "names", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L244-L264
train
jrfonseca/gprof2dot
gprof2dot.py
Profile.validate
def validate(self): """Validate the edges.""" for function in compat_itervalues(self.functions): for callee_id in compat_keys(function.calls): assert function.calls[callee_id].callee_id == callee_id if callee_id not in self.functions: sys....
python
def validate(self): """Validate the edges.""" for function in compat_itervalues(self.functions): for callee_id in compat_keys(function.calls): assert function.calls[callee_id].callee_id == callee_id if callee_id not in self.functions: sys....
[ "def", "validate", "(", "self", ")", ":", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "for", "callee_id", "in", "compat_keys", "(", "function", ".", "calls", ")", ":", "assert", "function", ".", "calls", "[", "c...
Validate the edges.
[ "Validate", "the", "edges", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L305-L313
train
jrfonseca/gprof2dot
gprof2dot.py
Profile.find_cycles
def find_cycles(self): """Find cycles using Tarjan's strongly connected components algorithm.""" # Apply the Tarjan's algorithm successively until all functions are visited stack = [] data = {} order = 0 for function in compat_itervalues(self.functions): orde...
python
def find_cycles(self): """Find cycles using Tarjan's strongly connected components algorithm.""" # Apply the Tarjan's algorithm successively until all functions are visited stack = [] data = {} order = 0 for function in compat_itervalues(self.functions): orde...
[ "def", "find_cycles", "(", "self", ")", ":", "# Apply the Tarjan's algorithm successively until all functions are visited", "stack", "=", "[", "]", "data", "=", "{", "}", "order", "=", "0", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions",...
Find cycles using Tarjan's strongly connected components algorithm.
[ "Find", "cycles", "using", "Tarjan", "s", "strongly", "connected", "components", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L315-L333
train
jrfonseca/gprof2dot
gprof2dot.py
Profile._tarjan
def _tarjan(self, function, order, stack, data): """Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm """ try: func_data = data[function.id] return order ex...
python
def _tarjan(self, function, order, stack, data): """Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm """ try: func_data = data[function.id] return order ex...
[ "def", "_tarjan", "(", "self", ",", "function", ",", "order", ",", "stack", ",", "data", ")", ":", "try", ":", "func_data", "=", "data", "[", "function", ".", "id", "]", "return", "order", "except", "KeyError", ":", "func_data", "=", "self", ".", "_T...
Tarjan's strongly connected components algorithm. See also: - http://en.wikipedia.org/wiki/Tarjan's_strongly_connected_components_algorithm
[ "Tarjan", "s", "strongly", "connected", "components", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L402-L441
train
jrfonseca/gprof2dot
gprof2dot.py
Profile.integrate
def integrate(self, outevent, inevent): """Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html """ # Sanity checking assert outevent not in self for ...
python
def integrate(self, outevent, inevent): """Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html """ # Sanity checking assert outevent not in self for ...
[ "def", "integrate", "(", "self", ",", "outevent", ",", "inevent", ")", ":", "# Sanity checking", "assert", "outevent", "not", "in", "self", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "assert", "outevent", "not", "i...
Propagate function time ratio along the function calls. Must be called after finding the cycles. See also: - http://citeseer.ist.psu.edu/graham82gprof.html
[ "Propagate", "function", "time", "ratio", "along", "the", "function", "calls", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L484-L515
train
jrfonseca/gprof2dot
gprof2dot.py
Profile._rank_cycle_function
def _rank_cycle_function(self, cycle, function, ranks): """Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm """ import heapq Q = [] Qd = {} p = {} visited = set([function]) ranks[function...
python
def _rank_cycle_function(self, cycle, function, ranks): """Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm """ import heapq Q = [] Qd = {} p = {} visited = set([function]) ranks[function...
[ "def", "_rank_cycle_function", "(", "self", ",", "cycle", ",", "function", ",", "ranks", ")", ":", "import", "heapq", "Q", "=", "[", "]", "Qd", "=", "{", "}", "p", "=", "{", "}", "visited", "=", "set", "(", "[", "function", "]", ")", "ranks", "["...
Dijkstra's shortest paths algorithm. See also: - http://en.wikipedia.org/wiki/Dijkstra's_algorithm
[ "Dijkstra", "s", "shortest", "paths", "algorithm", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L582-L629
train
jrfonseca/gprof2dot
gprof2dot.py
Profile.aggregate
def aggregate(self, event): """Aggregate an event for the whole profile.""" total = event.null() for function in compat_itervalues(self.functions): try: total = event.aggregate(total, function[event]) except UndefinedEvent: return ...
python
def aggregate(self, event): """Aggregate an event for the whole profile.""" total = event.null() for function in compat_itervalues(self.functions): try: total = event.aggregate(total, function[event]) except UndefinedEvent: return ...
[ "def", "aggregate", "(", "self", ",", "event", ")", ":", "total", "=", "event", ".", "null", "(", ")", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "try", ":", "total", "=", "event", ".", "aggregate", "(", "t...
Aggregate an event for the whole profile.
[ "Aggregate", "an", "event", "for", "the", "whole", "profile", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L668-L677
train
jrfonseca/gprof2dot
gprof2dot.py
Profile.prune
def prune(self, node_thres, edge_thres, paths, color_nodes_by_selftime): """Prune the profile""" # compute the prune ratios for function in compat_itervalues(self.functions): try: function.weight = function[TOTAL_TIME_RATIO] except UndefinedEvent: ...
python
def prune(self, node_thres, edge_thres, paths, color_nodes_by_selftime): """Prune the profile""" # compute the prune ratios for function in compat_itervalues(self.functions): try: function.weight = function[TOTAL_TIME_RATIO] except UndefinedEvent: ...
[ "def", "prune", "(", "self", ",", "node_thres", ",", "edge_thres", ",", "paths", ",", "color_nodes_by_selftime", ")", ":", "# compute the prune ratios", "for", "function", "in", "compat_itervalues", "(", "self", ".", "functions", ")", ":", "try", ":", "function"...
Prune the profile
[ "Prune", "the", "profile" ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L692-L751
train
jrfonseca/gprof2dot
gprof2dot.py
GprofParser.translate
def translate(self, mo): """Extract a structure from a match object, while translating the types in the process.""" attrs = {} groupdict = mo.groupdict() for name, value in compat_iteritems(groupdict): if value is None: value = None elif self._int_...
python
def translate(self, mo): """Extract a structure from a match object, while translating the types in the process.""" attrs = {} groupdict = mo.groupdict() for name, value in compat_iteritems(groupdict): if value is None: value = None elif self._int_...
[ "def", "translate", "(", "self", ",", "mo", ")", ":", "attrs", "=", "{", "}", "groupdict", "=", "mo", ".", "groupdict", "(", ")", "for", "name", ",", "value", "in", "compat_iteritems", "(", "groupdict", ")", ":", "if", "value", "is", "None", ":", "...
Extract a structure from a match object, while translating the types in the process.
[ "Extract", "a", "structure", "from", "a", "match", "object", "while", "translating", "the", "types", "in", "the", "process", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L1114-L1126
train
jrfonseca/gprof2dot
gprof2dot.py
AXEParser.parse_cg
def parse_cg(self): """Parse the call graph.""" # skip call graph header line = self.readline() while self._cg_header_re.match(line): line = self.readline() # process call graph entries entry_lines = [] # An EOF in readline terminates the program wit...
python
def parse_cg(self): """Parse the call graph.""" # skip call graph header line = self.readline() while self._cg_header_re.match(line): line = self.readline() # process call graph entries entry_lines = [] # An EOF in readline terminates the program wit...
[ "def", "parse_cg", "(", "self", ")", ":", "# skip call graph header", "line", "=", "self", ".", "readline", "(", ")", "while", "self", ".", "_cg_header_re", ".", "match", "(", "line", ")", ":", "line", "=", "self", ".", "readline", "(", ")", "# process c...
Parse the call graph.
[ "Parse", "the", "call", "graph", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L1541-L1558
train
jrfonseca/gprof2dot
gprof2dot.py
Theme.hsl_to_rgb
def hsl_to_rgb(self, h, s, l): """Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color """ h = h % 1.0 s = min(max(s, 0.0), 1.0) l = min(max(l, 0.0), 1.0) if l <= 0.5: m2 = l*(s + 1.0) e...
python
def hsl_to_rgb(self, h, s, l): """Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color """ h = h % 1.0 s = min(max(s, 0.0), 1.0) l = min(max(l, 0.0), 1.0) if l <= 0.5: m2 = l*(s + 1.0) e...
[ "def", "hsl_to_rgb", "(", "self", ",", "h", ",", "s", ",", "l", ")", ":", "h", "=", "h", "%", "1.0", "s", "=", "min", "(", "max", "(", "s", ",", "0.0", ")", ",", "1.0", ")", "l", "=", "min", "(", "max", "(", "l", ",", "0.0", ")", ",", ...
Convert a color from HSL color-model to RGB. See also: - http://www.w3.org/TR/css3-color/#hsl-color
[ "Convert", "a", "color", "from", "HSL", "color", "-", "model", "to", "RGB", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L2863-L2888
train
jrfonseca/gprof2dot
gprof2dot.py
DotWriter.wrap_function_name
def wrap_function_name(self, name): """Split the function name on multiple lines.""" if len(name) > 32: ratio = 2.0/3.0 height = max(int(len(name)/(1.0 - ratio) + 0.5), 1) width = max(len(name)/height, 32) # TODO: break lines in symbols name =...
python
def wrap_function_name(self, name): """Split the function name on multiple lines.""" if len(name) > 32: ratio = 2.0/3.0 height = max(int(len(name)/(1.0 - ratio) + 0.5), 1) width = max(len(name)/height, 32) # TODO: break lines in symbols name =...
[ "def", "wrap_function_name", "(", "self", ",", "name", ")", ":", "if", "len", "(", "name", ")", ">", "32", ":", "ratio", "=", "2.0", "/", "3.0", "height", "=", "max", "(", "int", "(", "len", "(", "name", ")", "/", "(", "1.0", "-", "ratio", ")",...
Split the function name on multiple lines.
[ "Split", "the", "function", "name", "on", "multiple", "lines", "." ]
0500e89f001e555f5eaa32e70793b4875f2f70db
https://github.com/jrfonseca/gprof2dot/blob/0500e89f001e555f5eaa32e70793b4875f2f70db/gprof2dot.py#L2974-L2989
train
danielhrisca/asammdf
asammdf/blocks/utils.py
matlab_compatible
def matlab_compatible(name): """ make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab """ compatible_name = [ch if ch in ALLOWED_MATLAB_CH...
python
def matlab_compatible(name): """ make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab """ compatible_name = [ch if ch in ALLOWED_MATLAB_CH...
[ "def", "matlab_compatible", "(", "name", ")", ":", "compatible_name", "=", "[", "ch", "if", "ch", "in", "ALLOWED_MATLAB_CHARS", "else", "\"_\"", "for", "ch", "in", "name", "]", "compatible_name", "=", "\"\"", ".", "join", "(", "compatible_name", ")", "if", ...
make a channel name compatible with Matlab variable naming Parameters ---------- name : str channel name Returns ------- compatible_name : str channel name compatible with Matlab
[ "make", "a", "channel", "name", "compatible", "with", "Matlab", "variable", "naming" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L149-L172
train
danielhrisca/asammdf
asammdf/blocks/utils.py
get_text_v3
def get_text_v3(address, stream, mapped=False): """ faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if ...
python
def get_text_v3(address, stream, mapped=False): """ faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if ...
[ "def", "get_text_v3", "(", "address", ",", "stream", ",", "mapped", "=", "False", ")", ":", "if", "address", "==", "0", ":", "return", "\"\"", "if", "mapped", ":", "size", ",", "=", "UINT16_uf", "(", "stream", ",", "address", "+", "2", ")", "text_byt...
faster way to extract strings from mdf versions 2 and 3 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string
[ "faster", "way", "to", "extract", "strings", "from", "mdf", "versions", "2", "and", "3", "TextBlock" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L175-L219
train
danielhrisca/asammdf
asammdf/blocks/utils.py
get_text_v4
def get_text_v4(address, stream, mapped=False): """ faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if address...
python
def get_text_v4(address, stream, mapped=False): """ faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string """ if address...
[ "def", "get_text_v4", "(", "address", ",", "stream", ",", "mapped", "=", "False", ")", ":", "if", "address", "==", "0", ":", "return", "\"\"", "if", "mapped", ":", "size", ",", "_", "=", "TWO_UINT64_uf", "(", "stream", ",", "address", "+", "8", ")", ...
faster way to extract strings from mdf version 4 TextBlock Parameters ---------- address : int TextBlock address stream : handle file IO handle Returns ------- text : str unicode string
[ "faster", "way", "to", "extract", "strings", "from", "mdf", "version", "4", "TextBlock" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L222-L266
train
danielhrisca/asammdf
asammdf/blocks/utils.py
get_fmt_v3
def get_fmt_v3(data_type, size): """convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format st...
python
def get_fmt_v3(data_type, size): """convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format st...
[ "def", "get_fmt_v3", "(", "data_type", ",", "size", ")", ":", "if", "data_type", "in", "{", "v3c", ".", "DATA_TYPE_STRING", ",", "v3c", ".", "DATA_TYPE_BYTEARRAY", "}", ":", "size", "=", "size", "//", "8", "if", "data_type", "==", "v3c", ".", "DATA_TYPE_...
convert mdf versions 2 and 3 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size Returns ------- fmt : str numpy compatible data type format string
[ "convert", "mdf", "versions", "2", "and", "3", "channel", "data", "type", "to", "numpy", "dtype", "format", "string" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L273-L330
train
danielhrisca/asammdf
asammdf/blocks/utils.py
get_fmt_v4
def get_fmt_v4(data_type, size, channel_type=v4c.CHANNEL_TYPE_VALUE): """convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Retu...
python
def get_fmt_v4(data_type, size, channel_type=v4c.CHANNEL_TYPE_VALUE): """convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Retu...
[ "def", "get_fmt_v4", "(", "data_type", ",", "size", ",", "channel_type", "=", "v4c", ".", "CHANNEL_TYPE_VALUE", ")", ":", "if", "data_type", "in", "v4c", ".", "NON_SCALAR_TYPES", ":", "size", "=", "size", "//", "8", "if", "data_type", "==", "v4c", ".", "...
convert mdf version 4 channel data type to numpy dtype format string Parameters ---------- data_type : int mdf channel data type size : int data bit size channel_type: int mdf channel type Returns ------- fmt : str numpy compatible data type format strin...
[ "convert", "mdf", "version", "4", "channel", "data", "type", "to", "numpy", "dtype", "format", "string" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L333-L409
train
danielhrisca/asammdf
asammdf/blocks/utils.py
fmt_to_datatype_v3
def fmt_to_datatype_v3(fmt, shape, array=False): """convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearra...
python
def fmt_to_datatype_v3(fmt, shape, array=False): """convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearra...
[ "def", "fmt_to_datatype_v3", "(", "fmt", ",", "shape", ",", "array", "=", "False", ")", ":", "size", "=", "fmt", ".", "itemsize", "*", "8", "if", "not", "array", "and", "shape", "[", "1", ":", "]", "and", "fmt", ".", "itemsize", "==", "1", "and", ...
convert numpy dtype format string to mdf versions 2 and 3 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and channel array Returns ------- data_ty...
[ "convert", "numpy", "dtype", "format", "string", "to", "mdf", "versions", "2", "and", "3", "channel", "data", "type", "and", "size" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L412-L469
train
danielhrisca/asammdf
asammdf/blocks/utils.py
info_to_datatype_v4
def info_to_datatype_v4(signed, little_endian): """map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- ...
python
def info_to_datatype_v4(signed, little_endian): """map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- ...
[ "def", "info_to_datatype_v4", "(", "signed", ",", "little_endian", ")", ":", "if", "signed", ":", "if", "little_endian", ":", "datatype", "=", "v4c", ".", "DATA_TYPE_SIGNED_INTEL", "else", ":", "datatype", "=", "v4c", ".", "DATA_TYPE_SIGNED_MOTOROLA", "else", ":...
map CAN signal to MDF integer types Parameters ---------- signed : bool signal is flagged as signed in the CAN database little_endian : bool signal is flagged as little endian (Intel) in the CAN database Returns ------- datatype : int integer code for MDF channel da...
[ "map", "CAN", "signal", "to", "MDF", "integer", "types" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L472-L500
train
danielhrisca/asammdf
asammdf/blocks/utils.py
fmt_to_datatype_v4
def fmt_to_datatype_v4(fmt, shape, array=False): """convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and c...
python
def fmt_to_datatype_v4(fmt, shape, array=False): """convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and c...
[ "def", "fmt_to_datatype_v4", "(", "fmt", ",", "shape", ",", "array", "=", "False", ")", ":", "size", "=", "fmt", ".", "itemsize", "*", "8", "if", "not", "array", "and", "shape", "[", "1", ":", "]", "and", "fmt", ".", "itemsize", "==", "1", "and", ...
convert numpy dtype format string to mdf version 4 channel data type and size Parameters ---------- fmt : numpy.dtype numpy data type shape : tuple numpy array shape array : bool disambiguate between bytearray and channel array Returns ------- data_type, siz...
[ "convert", "numpy", "dtype", "format", "string", "to", "mdf", "version", "4", "channel", "data", "type", "and", "size" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L503-L555
train
danielhrisca/asammdf
asammdf/blocks/utils.py
debug_channel
def debug_channel(mdf, group, channel, dependency, file=None): """ use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency chann...
python
def debug_channel(mdf, group, channel, dependency, file=None): """ use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency chann...
[ "def", "debug_channel", "(", "mdf", ",", "group", ",", "channel", ",", "dependency", ",", "file", "=", "None", ")", ":", "print", "(", "\"MDF\"", ",", "\"=\"", "*", "76", ",", "file", "=", "file", ")", "print", "(", "\"name:\"", ",", "mdf", ".", "n...
use this to print debug information in case of errors Parameters ---------- mdf : MDF source MDF object group : dict group channel : Channel channel object dependency : ChannelDependency channel dependency object
[ "use", "this", "to", "print", "debug", "information", "in", "case", "of", "errors" ]
3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66
https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/blocks/utils.py#L594-L643
train