repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
statueofmike/rtsp
scripts/rtp.py
RtpPacket.decode
def decode(self, byteStream): """Decode the RTP packet.""" self.header = bytearray(byteStream[:HEADER_SIZE]) self.payload = byteStream[HEADER_SIZE:]
python
def decode(self, byteStream): """Decode the RTP packet.""" self.header = bytearray(byteStream[:HEADER_SIZE]) self.payload = byteStream[HEADER_SIZE:]
[ "def", "decode", "(", "self", ",", "byteStream", ")", ":", "self", ".", "header", "=", "bytearray", "(", "byteStream", "[", ":", "HEADER_SIZE", "]", ")", "self", ".", "payload", "=", "byteStream", "[", "HEADER_SIZE", ":", "]" ]
Decode the RTP packet.
[ "Decode", "the", "RTP", "packet", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/rtp.py#L40-L43
statueofmike/rtsp
scripts/rtp.py
RtpPacket.timestamp
def timestamp(self): """Return timestamp.""" timestamp = self.header[4] << 24 | self.header[5] << 16 | self.header[6] << 8 | self.header[7] return int(timestamp)
python
def timestamp(self): """Return timestamp.""" timestamp = self.header[4] << 24 | self.header[5] << 16 | self.header[6] << 8 | self.header[7] return int(timestamp)
[ "def", "timestamp", "(", "self", ")", ":", "timestamp", "=", "self", ".", "header", "[", "4", "]", "<<", "24", "|", "self", ".", "header", "[", "5", "]", "<<", "16", "|", "self", ".", "header", "[", "6", "]", "<<", "8", "|", "self", ".", "hea...
Return timestamp.
[ "Return", "timestamp", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/rtp.py#L54-L57
statueofmike/rtsp
scripts/preview.py
preview_stream
def preview_stream(stream): """ Display stream in an OpenCV window until "q" key is pressed """ # together with waitkeys later, helps to close the video window effectively _cv2.startWindowThread() for frame in stream.frame_generator(): if frame is not None: _cv2.imshow('Video', ...
python
def preview_stream(stream): """ Display stream in an OpenCV window until "q" key is pressed """ # together with waitkeys later, helps to close the video window effectively _cv2.startWindowThread() for frame in stream.frame_generator(): if frame is not None: _cv2.imshow('Video', ...
[ "def", "preview_stream", "(", "stream", ")", ":", "# together with waitkeys later, helps to close the video window effectively", "_cv2", ".", "startWindowThread", "(", ")", "for", "frame", "in", "stream", ".", "frame_generator", "(", ")", ":", "if", "frame", "is", "no...
Display stream in an OpenCV window until "q" key is pressed
[ "Display", "stream", "in", "an", "OpenCV", "window", "until", "q", "key", "is", "pressed" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/preview.py#L9-L25
statueofmike/rtsp
scripts/rtsp.py
printrec
def printrec(recst): """ Pretty-printing rtsp strings """ try: recst = recst.decode('UTF-8') except AttributeError: pass recs=[ x for x in recst.split('\r\n') if x ] for rec in recs: print(rec) print("\n")
python
def printrec(recst): """ Pretty-printing rtsp strings """ try: recst = recst.decode('UTF-8') except AttributeError: pass recs=[ x for x in recst.split('\r\n') if x ] for rec in recs: print(rec) print("\n")
[ "def", "printrec", "(", "recst", ")", ":", "try", ":", "recst", "=", "recst", ".", "decode", "(", "'UTF-8'", ")", "except", "AttributeError", ":", "pass", "recs", "=", "[", "x", "for", "x", "in", "recst", ".", "split", "(", "'\\r\\n'", ")", "if", "...
Pretty-printing rtsp strings
[ "Pretty", "-", "printing", "rtsp", "strings" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/rtsp.py#L40-L50
statueofmike/rtsp
scripts/rtsp.py
get_resources
def get_resources(connection): """ Do an RTSP-DESCRIBE request, then parse out available resources from the response """ resp = connection.describe(verbose=False).split('\r\n') resources = [x.replace('a=control:','') for x in resp if (x.find('control:') != -1 and x[-1] != '*' )] return resources
python
def get_resources(connection): """ Do an RTSP-DESCRIBE request, then parse out available resources from the response """ resp = connection.describe(verbose=False).split('\r\n') resources = [x.replace('a=control:','') for x in resp if (x.find('control:') != -1 and x[-1] != '*' )] return resources
[ "def", "get_resources", "(", "connection", ")", ":", "resp", "=", "connection", ".", "describe", "(", "verbose", "=", "False", ")", ".", "split", "(", "'\\r\\n'", ")", "resources", "=", "[", "x", ".", "replace", "(", "'a=control:'", ",", "''", ")", "fo...
Do an RTSP-DESCRIBE request, then parse out available resources from the response
[ "Do", "an", "RTSP", "-", "DESCRIBE", "request", "then", "parse", "out", "available", "resources", "from", "the", "response" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/rtsp.py#L169-L173
statueofmike/rtsp
scripts/rtsp.py
RTSPConnection.setup
def setup(self,resource_path = "track1"): """ SETUP method defined by RTSP Protocol - https://tools.ietf.org/html/rfc7826#section-13.3 """ self.rtsp_seq += 1 uri = '/'.join([s.strip('/') for s in (self.server,self.stream_path,resource_path)]) ## example: SETUP rtsp://example.co...
python
def setup(self,resource_path = "track1"): """ SETUP method defined by RTSP Protocol - https://tools.ietf.org/html/rfc7826#section-13.3 """ self.rtsp_seq += 1 uri = '/'.join([s.strip('/') for s in (self.server,self.stream_path,resource_path)]) ## example: SETUP rtsp://example.co...
[ "def", "setup", "(", "self", ",", "resource_path", "=", "\"track1\"", ")", ":", "self", ".", "rtsp_seq", "+=", "1", "uri", "=", "'/'", ".", "join", "(", "[", "s", ".", "strip", "(", "'/'", ")", "for", "s", "in", "(", "self", ".", "server", ",", ...
SETUP method defined by RTSP Protocol - https://tools.ietf.org/html/rfc7826#section-13.3
[ "SETUP", "method", "defined", "by", "RTSP", "Protocol", "-", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc7826#section", "-", "13", ".", "3" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/rtsp.py#L153-L167
statueofmike/rtsp
scripts/ffmpeg_client.py
FFmpegClient.fetch_image
def fetch_image(self,rtsp_server_uri = _source,timeout_secs = 15): """ Fetch a single frame using FFMPEG. Convert to PIL Image. Slow. """ self._check_ffmpeg() cmd = "ffmpeg -rtsp_transport tcp -i {} -loglevel quiet -frames 1 -f image2pipe -".format(rtsp_server_uri) #stdout = _s...
python
def fetch_image(self,rtsp_server_uri = _source,timeout_secs = 15): """ Fetch a single frame using FFMPEG. Convert to PIL Image. Slow. """ self._check_ffmpeg() cmd = "ffmpeg -rtsp_transport tcp -i {} -loglevel quiet -frames 1 -f image2pipe -".format(rtsp_server_uri) #stdout = _s...
[ "def", "fetch_image", "(", "self", ",", "rtsp_server_uri", "=", "_source", ",", "timeout_secs", "=", "15", ")", ":", "self", ".", "_check_ffmpeg", "(", ")", "cmd", "=", "\"ffmpeg -rtsp_transport tcp -i {} -loglevel quiet -frames 1 -f image2pipe -\"", ".", "format", "(...
Fetch a single frame using FFMPEG. Convert to PIL Image. Slow.
[ "Fetch", "a", "single", "frame", "using", "FFMPEG", ".", "Convert", "to", "PIL", "Image", ".", "Slow", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/ffmpeg_client.py#L28-L42
statueofmike/rtsp
scripts/others/rtsp.py
exec_cmd
def exec_cmd(rtsp,cmd): '''根据命令执行操作''' global CUR_RANGE,CUR_SCALE if cmd in ('exit','teardown'): rtsp.do_teardown() elif cmd == 'pause': CUR_SCALE = 1; CUR_RANGE = 'npt=now-' rtsp.do_pause() elif cmd == 'help': PRINT(play_ctrl_help()) elif cmd == 'forward': ...
python
def exec_cmd(rtsp,cmd): '''根据命令执行操作''' global CUR_RANGE,CUR_SCALE if cmd in ('exit','teardown'): rtsp.do_teardown() elif cmd == 'pause': CUR_SCALE = 1; CUR_RANGE = 'npt=now-' rtsp.do_pause() elif cmd == 'help': PRINT(play_ctrl_help()) elif cmd == 'forward': ...
[ "def", "exec_cmd", "(", "rtsp", ",", "cmd", ")", ":", "global", "CUR_RANGE", ",", "CUR_SCALE", "if", "cmd", "in", "(", "'exit'", ",", "'teardown'", ")", ":", "rtsp", ".", "do_teardown", "(", ")", "elif", "cmd", "==", "'pause'", ":", "CUR_SCALE", "=", ...
根据命令执行操作
[ "根据命令执行操作" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L293-L320
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._parse_url
def _parse_url(self,url): '''解析url,返回(ip,port,target)三元组''' (ip,port,target) = ('',DEFAULT_SERVER_PORT,'') m = re.match(r'[rtspRTSP:/]+(?P<ip>(\d{1,3}\.){3}\d{1,3})(:(?P<port>\d+))?(?P<target>.*)',url) if m is not None: ip = m.group('ip') port = int(m.grou...
python
def _parse_url(self,url): '''解析url,返回(ip,port,target)三元组''' (ip,port,target) = ('',DEFAULT_SERVER_PORT,'') m = re.match(r'[rtspRTSP:/]+(?P<ip>(\d{1,3}\.){3}\d{1,3})(:(?P<port>\d+))?(?P<target>.*)',url) if m is not None: ip = m.group('ip') port = int(m.grou...
[ "def", "_parse_url", "(", "self", ",", "url", ")", ":", "(", "ip", ",", "port", ",", "target", ")", "=", "(", "''", ",", "DEFAULT_SERVER_PORT", ",", "''", ")", "m", "=", "re", ".", "match", "(", "r'[rtspRTSP:/]+(?P<ip>(\\d{1,3}\\.){3}\\d{1,3})(:(?P<port>\\d+...
解析url,返回(ip,port,target)三元组
[ "解析url", "返回", "(", "ip", "port", "target", ")", "三元组" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L86-L95
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._connect_server
def _connect_server(self): '''连接服务器,建立socket''' try: self._sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self._sock.connect((self._server_ip,self._server_port)) #PRINT('Connect [%s:%d] success!'%(self._server_ip,self._server_port), GREEN) except sock...
python
def _connect_server(self): '''连接服务器,建立socket''' try: self._sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self._sock.connect((self._server_ip,self._server_port)) #PRINT('Connect [%s:%d] success!'%(self._server_ip,self._server_port), GREEN) except sock...
[ "def", "_connect_server", "(", "self", ")", ":", "try", ":", "self", ".", "_sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "self", ".", "_sock", ".", "connect", "(", "(", "self", ".", "_ser...
连接服务器,建立socket
[ "连接服务器", "建立socket" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L97-L106
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._update_dest_ip
def _update_dest_ip(self): '''如果未指定DEST_IP,默认与RTSP使用相同IP''' global DEST_IP if not DEST_IP: DEST_IP = self._sock.getsockname()[0] PRINT('DEST_IP: %s\n'%DEST_IP, CYAN)
python
def _update_dest_ip(self): '''如果未指定DEST_IP,默认与RTSP使用相同IP''' global DEST_IP if not DEST_IP: DEST_IP = self._sock.getsockname()[0] PRINT('DEST_IP: %s\n'%DEST_IP, CYAN)
[ "def", "_update_dest_ip", "(", "self", ")", ":", "global", "DEST_IP", "if", "not", "DEST_IP", ":", "DEST_IP", "=", "self", ".", "_sock", ".", "getsockname", "(", ")", "[", "0", "]", "PRINT", "(", "'DEST_IP: %s\\n'", "%", "DEST_IP", ",", "CYAN", ")" ]
如果未指定DEST_IP,默认与RTSP使用相同IP
[ "如果未指定DEST_IP", "默认与RTSP使用相同IP" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L108-L113
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient.recv_msg
def recv_msg(self): '''收取一个完整响应消息或ANNOUNCE通知消息''' try: while True: if HEADER_END_STR in self._recv_buf: break more = self._sock.recv(2048) if not more: break self._recv_buf += more except socket.error, e: PRI...
python
def recv_msg(self): '''收取一个完整响应消息或ANNOUNCE通知消息''' try: while True: if HEADER_END_STR in self._recv_buf: break more = self._sock.recv(2048) if not more: break self._recv_buf += more except socket.error, e: PRI...
[ "def", "recv_msg", "(", "self", ")", ":", "try", ":", "while", "True", ":", "if", "HEADER_END_STR", "in", "self", ".", "_recv_buf", ":", "break", "more", "=", "self", ".", "_sock", ".", "recv", "(", "2048", ")", "if", "not", "more", ":", "break", "...
收取一个完整响应消息或ANNOUNCE通知消息
[ "收取一个完整响应消息或ANNOUNCE通知消息" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L115-L133
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._get_content_length
def _get_content_length(self,msg): '''从消息中解析Content-length''' m = re.search(r'[Cc]ontent-length:\s?(?P<len>\d+)',msg,re.S) return (m and int(m.group('len'))) or 0
python
def _get_content_length(self,msg): '''从消息中解析Content-length''' m = re.search(r'[Cc]ontent-length:\s?(?P<len>\d+)',msg,re.S) return (m and int(m.group('len'))) or 0
[ "def", "_get_content_length", "(", "self", ",", "msg", ")", ":", "m", "=", "re", ".", "search", "(", "r'[Cc]ontent-length:\\s?(?P<len>\\d+)'", ",", "msg", ",", "re", ".", "S", ")", "return", "(", "m", "and", "int", "(", "m", ".", "group", "(", "'len'",...
从消息中解析Content-length
[ "从消息中解析Content", "-", "length" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L135-L138
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._process_response
def _process_response(self,msg): '''处理响应消息''' status,headers,body = self._parse_response(msg) rsp_cseq = int(headers['cseq']) if self._cseq_map[rsp_cseq] != 'GET_PARAMETER': PRINT(self._get_time_str() + '\n' + msg) if status == 302: self.location = headers...
python
def _process_response(self,msg): '''处理响应消息''' status,headers,body = self._parse_response(msg) rsp_cseq = int(headers['cseq']) if self._cseq_map[rsp_cseq] != 'GET_PARAMETER': PRINT(self._get_time_str() + '\n' + msg) if status == 302: self.location = headers...
[ "def", "_process_response", "(", "self", ",", "msg", ")", ":", "status", ",", "headers", ",", "body", "=", "self", ".", "_parse_response", "(", "msg", ")", "rsp_cseq", "=", "int", "(", "headers", "[", "'cseq'", "]", ")", "if", "self", ".", "_cseq_map",...
处理响应消息
[ "处理响应消息" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L145-L163
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._process_announce
def _process_announce(self,msg): '''处理ANNOUNCE通知消息''' global CUR_RANGE,CUR_SCALE PRINT(msg) headers = self._parse_header_params(msg.splitlines()[1:]) x_notice_val = int(headers['x-notice']) if x_notice_val in (X_NOTICE_EOS,X_NOTICE_BOS): CUR_SCALE = 1 ...
python
def _process_announce(self,msg): '''处理ANNOUNCE通知消息''' global CUR_RANGE,CUR_SCALE PRINT(msg) headers = self._parse_header_params(msg.splitlines()[1:]) x_notice_val = int(headers['x-notice']) if x_notice_val in (X_NOTICE_EOS,X_NOTICE_BOS): CUR_SCALE = 1 ...
[ "def", "_process_announce", "(", "self", ",", "msg", ")", ":", "global", "CUR_RANGE", ",", "CUR_SCALE", "PRINT", "(", "msg", ")", "headers", "=", "self", ".", "_parse_header_params", "(", "msg", ".", "splitlines", "(", ")", "[", "1", ":", "]", ")", "x_...
处理ANNOUNCE通知消息
[ "处理ANNOUNCE通知消息" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L165-L175
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._parse_response
def _parse_response(self,msg): '''解析响应消息''' header,body = msg.split(HEADER_END_STR)[:2] header_lines = header.splitlines() version,status = header_lines[0].split(None,2)[:2] headers = self._parse_header_params(header_lines[1:]) return int(status),headers,body
python
def _parse_response(self,msg): '''解析响应消息''' header,body = msg.split(HEADER_END_STR)[:2] header_lines = header.splitlines() version,status = header_lines[0].split(None,2)[:2] headers = self._parse_header_params(header_lines[1:]) return int(status),headers,body
[ "def", "_parse_response", "(", "self", ",", "msg", ")", ":", "header", ",", "body", "=", "msg", ".", "split", "(", "HEADER_END_STR", ")", "[", ":", "2", "]", "header_lines", "=", "header", ".", "splitlines", "(", ")", "version", ",", "status", "=", "...
解析响应消息
[ "解析响应消息" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L177-L183
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._parse_header_params
def _parse_header_params(self,header_param_lines): '''解析头部参数''' headers = {} for line in header_param_lines: if line.strip(): # 跳过空行 key,val = line.split(':', 1) headers[key.lower()] = val.strip() return headers
python
def _parse_header_params(self,header_param_lines): '''解析头部参数''' headers = {} for line in header_param_lines: if line.strip(): # 跳过空行 key,val = line.split(':', 1) headers[key.lower()] = val.strip() return headers
[ "def", "_parse_header_params", "(", "self", ",", "header_param_lines", ")", ":", "headers", "=", "{", "}", "for", "line", "in", "header_param_lines", ":", "if", "line", ".", "strip", "(", ")", ":", "# 跳过空行", "key", ",", "val", "=", "line", ".", "split", ...
解析头部参数
[ "解析头部参数" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L185-L192
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._parse_track_id
def _parse_track_id(self,sdp): '''从sdp中解析trackID=2形式的字符串''' m = re.search(r'a=control:(?P<trackid>[\w=\d]+)',sdp,re.S) return (m and m.group('trackid')) or ''
python
def _parse_track_id(self,sdp): '''从sdp中解析trackID=2形式的字符串''' m = re.search(r'a=control:(?P<trackid>[\w=\d]+)',sdp,re.S) return (m and m.group('trackid')) or ''
[ "def", "_parse_track_id", "(", "self", ",", "sdp", ")", ":", "m", "=", "re", ".", "search", "(", "r'a=control:(?P<trackid>[\\w=\\d]+)'", ",", "sdp", ",", "re", ".", "S", ")", "return", "(", "m", "and", "m", ".", "group", "(", "'trackid'", ")", ")", "...
从sdp中解析trackID=2形式的字符串
[ "从sdp中解析trackID", "=", "2形式的字符串" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L194-L197
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._sendmsg
def _sendmsg(self,method,url,headers): '''发送消息''' msg = '%s %s %s'%(method,url,RTSP_VERSION) headers['User-Agent'] = DEFAULT_USERAGENT cseq = self._next_seq() self._cseq_map[cseq] = method headers['CSeq'] = str(cseq) if self._session_id: headers['Session'] = self....
python
def _sendmsg(self,method,url,headers): '''发送消息''' msg = '%s %s %s'%(method,url,RTSP_VERSION) headers['User-Agent'] = DEFAULT_USERAGENT cseq = self._next_seq() self._cseq_map[cseq] = method headers['CSeq'] = str(cseq) if self._session_id: headers['Session'] = self....
[ "def", "_sendmsg", "(", "self", ",", "method", ",", "url", ",", "headers", ")", ":", "msg", "=", "'%s %s %s'", "%", "(", "method", ",", "url", ",", "RTSP_VERSION", ")", "headers", "[", "'User-Agent'", "]", "=", "DEFAULT_USERAGENT", "cseq", "=", "self", ...
发送消息
[ "发送消息" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L203-L219
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient._get_transport_type
def _get_transport_type(self): '''获取SETUP时需要的Transport字符串参数''' transport_str = '' ip_type = 'unicast' #if IPAddress(DEST_IP).is_unicast() else 'multicast' for t in TRANSPORT_TYPE_LIST: if t not in TRANSPORT_TYPE_MAP: PRINT('Error param: %s'%t,RED) ...
python
def _get_transport_type(self): '''获取SETUP时需要的Transport字符串参数''' transport_str = '' ip_type = 'unicast' #if IPAddress(DEST_IP).is_unicast() else 'multicast' for t in TRANSPORT_TYPE_LIST: if t not in TRANSPORT_TYPE_MAP: PRINT('Error param: %s'%t,RED) ...
[ "def", "_get_transport_type", "(", "self", ")", ":", "transport_str", "=", "''", "ip_type", "=", "'unicast'", "#if IPAddress(DEST_IP).is_unicast() else 'multicast'", "for", "t", "in", "TRANSPORT_TYPE_LIST", ":", "if", "t", "not", "in", "TRANSPORT_TYPE_MAP", ":", "PRIN...
获取SETUP时需要的Transport字符串参数
[ "获取SETUP时需要的Transport字符串参数" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L221-L233
statueofmike/rtsp
scripts/others/rtsp.py
RTSPClient.send_heart_beat_msg
def send_heart_beat_msg(self): '''定时发送GET_PARAMETER消息保活''' if self.running: self.do_get_parameter() threading.Timer(HEARTBEAT_INTERVAL, self.send_heart_beat_msg).start()
python
def send_heart_beat_msg(self): '''定时发送GET_PARAMETER消息保活''' if self.running: self.do_get_parameter() threading.Timer(HEARTBEAT_INTERVAL, self.send_heart_beat_msg).start()
[ "def", "send_heart_beat_msg", "(", "self", ")", ":", "if", "self", ".", "running", ":", "self", ".", "do_get_parameter", "(", ")", "threading", ".", "Timer", "(", "HEARTBEAT_INTERVAL", ",", "self", ".", "send_heart_beat_msg", ")", ".", "start", "(", ")" ]
定时发送GET_PARAMETER消息保活
[ "定时发送GET_PARAMETER消息保活" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rtsp.py#L269-L273
statueofmike/rtsp
scripts/others/rts2.py
Client.setupMovie
def setupMovie(self): """Setup button handler.""" if self.state == self.INIT: self.sendRtspRequest(self.SETUP)
python
def setupMovie(self): """Setup button handler.""" if self.state == self.INIT: self.sendRtspRequest(self.SETUP)
[ "def", "setupMovie", "(", "self", ")", ":", "if", "self", ".", "state", "==", "self", ".", "INIT", ":", "self", ".", "sendRtspRequest", "(", "self", ".", "SETUP", ")" ]
Setup button handler.
[ "Setup", "button", "handler", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L37-L40
statueofmike/rtsp
scripts/others/rts2.py
Client.exitClient
def exitClient(self): """Teardown button handler.""" self.sendRtspRequest(self.TEARDOWN) #self.handler() os.remove(CACHE_FILE_NAME + str(self.sessionId) + CACHE_FILE_EXT) # Delete the cache image from video rate = float(self.counter/self.frameNbr) print('-'*60 + "\nRTP Packet Loss Rate :" + str(...
python
def exitClient(self): """Teardown button handler.""" self.sendRtspRequest(self.TEARDOWN) #self.handler() os.remove(CACHE_FILE_NAME + str(self.sessionId) + CACHE_FILE_EXT) # Delete the cache image from video rate = float(self.counter/self.frameNbr) print('-'*60 + "\nRTP Packet Loss Rate :" + str(...
[ "def", "exitClient", "(", "self", ")", ":", "self", ".", "sendRtspRequest", "(", "self", ".", "TEARDOWN", ")", "#self.handler()", "os", ".", "remove", "(", "CACHE_FILE_NAME", "+", "str", "(", "self", ".", "sessionId", ")", "+", "CACHE_FILE_EXT", ")", "# De...
Teardown button handler.
[ "Teardown", "button", "handler", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L42-L49
statueofmike/rtsp
scripts/others/rts2.py
Client.pauseMovie
def pauseMovie(self): """Pause button handler.""" if self.state == self.PLAYING: self.sendRtspRequest(self.PAUSE)
python
def pauseMovie(self): """Pause button handler.""" if self.state == self.PLAYING: self.sendRtspRequest(self.PAUSE)
[ "def", "pauseMovie", "(", "self", ")", ":", "if", "self", ".", "state", "==", "self", ".", "PLAYING", ":", "self", ".", "sendRtspRequest", "(", "self", ".", "PAUSE", ")" ]
Pause button handler.
[ "Pause", "button", "handler", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L51-L54
statueofmike/rtsp
scripts/others/rts2.py
Client.updateMovie
def updateMovie(self, imageFile): """Update the image file as video frame in the GUI.""" try: photo = ImageTk.PhotoImage(Image.open(imageFile)) #stuck here !!!!!! except: print("photo error") print('-'*60) traceback.print_exc(file=sys.stdout) print('-'*60) self.label.confi...
python
def updateMovie(self, imageFile): """Update the image file as video frame in the GUI.""" try: photo = ImageTk.PhotoImage(Image.open(imageFile)) #stuck here !!!!!! except: print("photo error") print('-'*60) traceback.print_exc(file=sys.stdout) print('-'*60) self.label.confi...
[ "def", "updateMovie", "(", "self", ",", "imageFile", ")", ":", "try", ":", "photo", "=", "ImageTk", ".", "PhotoImage", "(", "Image", ".", "open", "(", "imageFile", ")", ")", "#stuck here !!!!!!", "except", ":", "print", "(", "\"photo error\"", ")", "print"...
Update the image file as video frame in the GUI.
[ "Update", "the", "image", "file", "as", "video", "frame", "in", "the", "GUI", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L124-L135
statueofmike/rtsp
scripts/others/rts2.py
Client.connectToServer
def connectToServer(self): """Connect to the Server. Start a new RTSP/TCP session.""" self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.rtspSocket.connect((self.serverAddr, self.serverPort)) except: tkinter.messagebox.showwarning('Connection Failed', 'Connection t...
python
def connectToServer(self): """Connect to the Server. Start a new RTSP/TCP session.""" self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.rtspSocket.connect((self.serverAddr, self.serverPort)) except: tkinter.messagebox.showwarning('Connection Failed', 'Connection t...
[ "def", "connectToServer", "(", "self", ")", ":", "self", ".", "rtspSocket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "self", ".", "rtspSocket", ".", "connect", "(", "(", "self", "....
Connect to the Server. Start a new RTSP/TCP session.
[ "Connect", "to", "the", "Server", ".", "Start", "a", "new", "RTSP", "/", "TCP", "session", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L137-L143
statueofmike/rtsp
scripts/others/rts2.py
Client.sendRtspRequest
def sendRtspRequest(self, requestCode): """Send RTSP request to the server.""" #------------- # TO COMPLETE #------------- # Setup request if requestCode == self.SETUP and self.state == self.INIT: threading.Thread(target=self.recvRtspReply).start() # Update RTSP sequence number. ...
python
def sendRtspRequest(self, requestCode): """Send RTSP request to the server.""" #------------- # TO COMPLETE #------------- # Setup request if requestCode == self.SETUP and self.state == self.INIT: threading.Thread(target=self.recvRtspReply).start() # Update RTSP sequence number. ...
[ "def", "sendRtspRequest", "(", "self", ",", "requestCode", ")", ":", "#-------------", "# TO COMPLETE", "#-------------", "# Setup request", "if", "requestCode", "==", "self", ".", "SETUP", "and", "self", ".", "state", "==", "self", ".", "INIT", ":", "threading"...
Send RTSP request to the server.
[ "Send", "RTSP", "request", "to", "the", "server", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L145-L214
statueofmike/rtsp
scripts/others/rts2.py
Client.recvRtspReply
def recvRtspReply(self): """Receive RTSP reply from the server.""" while True: reply = self.rtspSocket.recv(1024) if reply: self.parseRtspReply(reply) # Close the RTSP socket upon requesting Teardown if self.requestSent == self.TEARDOWN: self.rtspSocket.shutdown(socket....
python
def recvRtspReply(self): """Receive RTSP reply from the server.""" while True: reply = self.rtspSocket.recv(1024) if reply: self.parseRtspReply(reply) # Close the RTSP socket upon requesting Teardown if self.requestSent == self.TEARDOWN: self.rtspSocket.shutdown(socket....
[ "def", "recvRtspReply", "(", "self", ")", ":", "while", "True", ":", "reply", "=", "self", ".", "rtspSocket", ".", "recv", "(", "1024", ")", "if", "reply", ":", "self", ".", "parseRtspReply", "(", "reply", ")", "# Close the RTSP socket upon requesting Teardown...
Receive RTSP reply from the server.
[ "Receive", "RTSP", "reply", "from", "the", "server", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L221-L233
statueofmike/rtsp
scripts/others/rts2.py
Client.parseRtspReply
def parseRtspReply(self, data): print("Parsing Received Rtsp data...") """Parse the RTSP reply from the server.""" lines = data.split('\n') seqNum = int(lines[1].split(' ')[1]) # Process only if the server reply's sequence number is the same as the request's if seqNum == self.rtspSeq: se...
python
def parseRtspReply(self, data): print("Parsing Received Rtsp data...") """Parse the RTSP reply from the server.""" lines = data.split('\n') seqNum = int(lines[1].split(' ')[1]) # Process only if the server reply's sequence number is the same as the request's if seqNum == self.rtspSeq: se...
[ "def", "parseRtspReply", "(", "self", ",", "data", ")", ":", "print", "(", "\"Parsing Received Rtsp data...\"", ")", "lines", "=", "data", ".", "split", "(", "'\\n'", ")", "seqNum", "=", "int", "(", "lines", "[", "1", "]", ".", "split", "(", "' '", ")"...
Parse the RTSP reply from the server.
[ "Parse", "the", "RTSP", "reply", "from", "the", "server", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L235-L278
statueofmike/rtsp
scripts/others/rts2.py
Client.openRtpPort
def openRtpPort(self): """Open RTP socket binded to a specified port.""" #------------- # TO COMPLETE #------------- # Create a new datagram socket to receive RTP packets from the server # self.rtpSocket = ... # Set the timeout value of the socket to 0.5sec # ... self.rtpSocket.set...
python
def openRtpPort(self): """Open RTP socket binded to a specified port.""" #------------- # TO COMPLETE #------------- # Create a new datagram socket to receive RTP packets from the server # self.rtpSocket = ... # Set the timeout value of the socket to 0.5sec # ... self.rtpSocket.set...
[ "def", "openRtpPort", "(", "self", ")", ":", "#-------------", "# TO COMPLETE", "#-------------", "# Create a new datagram socket to receive RTP packets from the server", "# self.rtpSocket = ...", "# Set the timeout value of the socket to 0.5sec", "# ...", "self", ".", "rtpSocket", "...
Open RTP socket binded to a specified port.
[ "Open", "RTP", "socket", "binded", "to", "a", "specified", "port", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.py#L280-L305
statueofmike/rtsp
rtsp/cvstream.py
PicamVideoFeed.read
def read(self): """https://picamera.readthedocs.io/en/release-1.13/recipes1.html#capturing-to-a-pil-image""" stream = BytesIO() self.cam.capture(stream, format='png') # "Rewind" the stream to the beginning so we can read its content stream.seek(0) return Image.open(stream...
python
def read(self): """https://picamera.readthedocs.io/en/release-1.13/recipes1.html#capturing-to-a-pil-image""" stream = BytesIO() self.cam.capture(stream, format='png') # "Rewind" the stream to the beginning so we can read its content stream.seek(0) return Image.open(stream...
[ "def", "read", "(", "self", ")", ":", "stream", "=", "BytesIO", "(", ")", "self", ".", "cam", ".", "capture", "(", "stream", ",", "format", "=", "'png'", ")", "# \"Rewind\" the stream to the beginning so we can read its content", "stream", ".", "seek", "(", "0...
https://picamera.readthedocs.io/en/release-1.13/recipes1.html#capturing-to-a-pil-image
[ "https", ":", "//", "picamera", ".", "readthedocs", ".", "io", "/", "en", "/", "release", "-", "1", ".", "13", "/", "recipes1", ".", "html#capturing", "-", "to", "-", "a", "-", "pil", "-", "image" ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/rtsp/cvstream.py#L24-L30
statueofmike/rtsp
rtsp/cvstream.py
LocalVideoFeed.preview
def preview(self): """ Blocking function. Opens OpenCV window to display stream. """ win_name = 'Camera' cv2.namedWindow(win_name, cv2.WINDOW_AUTOSIZE) cv2.moveWindow(win_name,20,20) self.open() while(self.isOpened()): cv2.imshow(win_name,self._stream.read()[1...
python
def preview(self): """ Blocking function. Opens OpenCV window to display stream. """ win_name = 'Camera' cv2.namedWindow(win_name, cv2.WINDOW_AUTOSIZE) cv2.moveWindow(win_name,20,20) self.open() while(self.isOpened()): cv2.imshow(win_name,self._stream.read()[1...
[ "def", "preview", "(", "self", ")", ":", "win_name", "=", "'Camera'", "cv2", ".", "namedWindow", "(", "win_name", ",", "cv2", ".", "WINDOW_AUTOSIZE", ")", "cv2", ".", "moveWindow", "(", "win_name", ",", "20", ",", "20", ")", "self", ".", "open", "(", ...
Blocking function. Opens OpenCV window to display stream.
[ "Blocking", "function", ".", "Opens", "OpenCV", "window", "to", "display", "stream", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/rtsp/cvstream.py#L87-L99
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.createWidgets
def createWidgets(self): """Build GUI.""" # Create Setup button self.setup = Button(self.master, width=20, padx=3, pady=3) self.setup["text"] = "Setup" self.setup["command"] = self.setupMovie self.setup.grid(row=1, column=0, padx=2, pady=2) # Create Play button self.start = Button(self....
python
def createWidgets(self): """Build GUI.""" # Create Setup button self.setup = Button(self.master, width=20, padx=3, pady=3) self.setup["text"] = "Setup" self.setup["command"] = self.setupMovie self.setup.grid(row=1, column=0, padx=2, pady=2) # Create Play button self.start = Button(self....
[ "def", "createWidgets", "(", "self", ")", ":", "# Create Setup button", "self", ".", "setup", "=", "Button", "(", "self", ".", "master", ",", "width", "=", "20", ",", "padx", "=", "3", ",", "pady", "=", "3", ")", "self", ".", "setup", "[", "\"text\""...
Build GUI.
[ "Build", "GUI", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L42-L70
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.playMovie
def playMovie(self): """Play button handler.""" if self.state == self.READY: # Create a new thread to listen for RTP packets print "Playing Movie" threading.Thread(target=self.listenRtp).start() self.playEvent = threading.Event() self.playEvent.clear() self.sendRtspRequest(se...
python
def playMovie(self): """Play button handler.""" if self.state == self.READY: # Create a new thread to listen for RTP packets print "Playing Movie" threading.Thread(target=self.listenRtp).start() self.playEvent = threading.Event() self.playEvent.clear() self.sendRtspRequest(se...
[ "def", "playMovie", "(", "self", ")", ":", "if", "self", ".", "state", "==", "self", ".", "READY", ":", "# Create a new thread to listen for RTP packets", "print", "\"Playing Movie\"", "threading", ".", "Thread", "(", "target", "=", "self", ".", "listenRtp", ")"...
Play button handler.
[ "Play", "button", "handler", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L92-L100
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.writeFrame
def writeFrame(self, data): """Write the received frame to a temp image file. Return the image file.""" cachename = CACHE_FILE_NAME + str(self.sessionId) + CACHE_FILE_EXT try: file = open(cachename, "wb") except: print "file open error" try: file.write(data) except: pr...
python
def writeFrame(self, data): """Write the received frame to a temp image file. Return the image file.""" cachename = CACHE_FILE_NAME + str(self.sessionId) + CACHE_FILE_EXT try: file = open(cachename, "wb") except: print "file open error" try: file.write(data) except: pr...
[ "def", "writeFrame", "(", "self", ",", "data", ")", ":", "cachename", "=", "CACHE_FILE_NAME", "+", "str", "(", "self", ".", "sessionId", ")", "+", "CACHE_FILE_EXT", "try", ":", "file", "=", "open", "(", "cachename", ",", "\"wb\"", ")", "except", ":", "...
Write the received frame to a temp image file. Return the image file.
[ "Write", "the", "received", "frame", "to", "a", "temp", "image", "file", ".", "Return", "the", "image", "file", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L141-L158
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.connectToServer
def connectToServer(self): """Connect to the Server. Start a new RTSP/TCP session.""" self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.rtspSocket.connect((self.serverAddr, self.serverPort)) except: tkMessageBox.showwarning('Connection Failed', 'Connection to \'%s...
python
def connectToServer(self): """Connect to the Server. Start a new RTSP/TCP session.""" self.rtspSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: self.rtspSocket.connect((self.serverAddr, self.serverPort)) except: tkMessageBox.showwarning('Connection Failed', 'Connection to \'%s...
[ "def", "connectToServer", "(", "self", ")", ":", "self", ".", "rtspSocket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "try", ":", "self", ".", "rtspSocket", ".", "connect", "(", "(", "self", "....
Connect to the Server. Start a new RTSP/TCP session.
[ "Connect", "to", "the", "Server", ".", "Start", "a", "new", "RTSP", "/", "TCP", "session", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L173-L179
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.openRtpPort
def openRtpPort(self): """Open RTP socket binded to a specified port.""" #------------- # TO COMPLETE #------------- # Create a new datagram socket to receive RTP packets from the server # self.rtpSocket = ... # Set the timeout value of the socket to 0.5sec # ... self.rtpSocket.set...
python
def openRtpPort(self): """Open RTP socket binded to a specified port.""" #------------- # TO COMPLETE #------------- # Create a new datagram socket to receive RTP packets from the server # self.rtpSocket = ... # Set the timeout value of the socket to 0.5sec # ... self.rtpSocket.set...
[ "def", "openRtpPort", "(", "self", ")", ":", "#-------------", "# TO COMPLETE", "#-------------", "# Create a new datagram socket to receive RTP packets from the server", "# self.rtpSocket = ...", "# Set the timeout value of the socket to 0.5sec", "# ...", "self", ".", "rtpSocket", "...
Open RTP socket binded to a specified port.
[ "Open", "RTP", "socket", "binded", "to", "a", "specified", "port", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L316-L341
statueofmike/rtsp
scripts/others/rts2.bak.py
Client.handler
def handler(self): """Handler on explicitly closing the GUI window.""" self.pauseMovie() if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"): self.exitClient() else: # When the user presses cancel, resume playing. #self.playMovie() print "Playing Movie" threadi...
python
def handler(self): """Handler on explicitly closing the GUI window.""" self.pauseMovie() if tkMessageBox.askokcancel("Quit?", "Are you sure you want to quit?"): self.exitClient() else: # When the user presses cancel, resume playing. #self.playMovie() print "Playing Movie" threadi...
[ "def", "handler", "(", "self", ")", ":", "self", ".", "pauseMovie", "(", ")", "if", "tkMessageBox", ".", "askokcancel", "(", "\"Quit?\"", ",", "\"Are you sure you want to quit?\"", ")", ":", "self", ".", "exitClient", "(", ")", "else", ":", "# When the user pr...
Handler on explicitly closing the GUI window.
[ "Handler", "on", "explicitly", "closing", "the", "GUI", "window", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/rts2.bak.py#L344-L355
statueofmike/rtsp
scripts/others/RtpPacket.py
RtpPacket.encode
def encode(self, version, padding, extension, cc, seqnum, marker, pt, ssrc, payload): """Encode the RTP packet with header fields and payload.""" timestamp = int(time()) print("timestamp: " + str(timestamp)) self.header = bytearray(HEADER_SIZE) #-------------- # TO COMPLETE #-------------- # Fill the h...
python
def encode(self, version, padding, extension, cc, seqnum, marker, pt, ssrc, payload): """Encode the RTP packet with header fields and payload.""" timestamp = int(time()) print("timestamp: " + str(timestamp)) self.header = bytearray(HEADER_SIZE) #-------------- # TO COMPLETE #-------------- # Fill the h...
[ "def", "encode", "(", "self", ",", "version", ",", "padding", ",", "extension", ",", "cc", ",", "seqnum", ",", "marker", ",", "pt", ",", "ssrc", ",", "payload", ")", ":", "timestamp", "=", "int", "(", "time", "(", ")", ")", "print", "(", "\"timesta...
Encode the RTP packet with header fields and payload.
[ "Encode", "the", "RTP", "packet", "with", "header", "fields", "and", "payload", "." ]
train
https://github.com/statueofmike/rtsp/blob/4816de2da3cc9966122c8511943e6db713052a17/scripts/others/RtpPacket.py#L17-L64
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
ChatThreadParser.skip
def skip(self): """ Eats through the input iterator without recording the content. """ for pos, element in self.element_iter: tag, class_attr = _tag_and_class_attr(element) if tag == "div" and "thread" in class_attr and pos == "end": break
python
def skip(self): """ Eats through the input iterator without recording the content. """ for pos, element in self.element_iter: tag, class_attr = _tag_and_class_attr(element) if tag == "div" and "thread" in class_attr and pos == "end": break
[ "def", "skip", "(", "self", ")", ":", "for", "pos", ",", "element", "in", "self", ".", "element_iter", ":", "tag", ",", "class_attr", "=", "_tag_and_class_attr", "(", "element", ")", "if", "tag", "==", "\"div\"", "and", "\"thread\"", "in", "class_attr", ...
Eats through the input iterator without recording the content.
[ "Eats", "through", "the", "input", "iterator", "without", "recording", "the", "content", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L131-L138
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
ChatThreadParser._process_element
def _process_element(self, pos, e): """ Parses an incoming HTML element/node for data. pos -- the part of the element being parsed (start/end) e -- the element being parsed """ tag, class_attr = _tag_and_class_attr(e) start_of_message = tag == '...
python
def _process_element(self, pos, e): """ Parses an incoming HTML element/node for data. pos -- the part of the element being parsed (start/end) e -- the element being parsed """ tag, class_attr = _tag_and_class_attr(e) start_of_message = tag == '...
[ "def", "_process_element", "(", "self", ",", "pos", ",", "e", ")", ":", "tag", ",", "class_attr", "=", "_tag_and_class_attr", "(", "e", ")", "start_of_message", "=", "tag", "==", "'div'", "and", "class_attr", "==", "'message'", "and", "pos", "==", "'start'...
Parses an incoming HTML element/node for data. pos -- the part of the element being parsed (start/end) e -- the element being parsed
[ "Parses", "an", "incoming", "HTML", "element", "/", "node", "for", "data", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L140-L192
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
MessageHtmlParser.should_record_thread
def should_record_thread(self, participants): """ Determines if the thread should be parsed based on the participants and the filter given. For example, if the filter states ['jack', 'billy joe'], then only threads with exactly two participants (excluding the owner of th...
python
def should_record_thread(self, participants): """ Determines if the thread should be parsed based on the participants and the filter given. For example, if the filter states ['jack', 'billy joe'], then only threads with exactly two participants (excluding the owner of th...
[ "def", "should_record_thread", "(", "self", ",", "participants", ")", ":", "if", "not", "self", ".", "thread_filter", ":", "return", "True", "if", "len", "(", "participants", ")", "!=", "len", "(", "self", ".", "thread_filter", ")", ":", "return", "False",...
Determines if the thread should be parsed based on the participants and the filter given. For example, if the filter states ['jack', 'billy joe'], then only threads with exactly two participants (excluding the owner of the chat history) containing someone with the first or last ...
[ "Determines", "if", "the", "thread", "should", "be", "parsed", "based", "on", "the", "participants", "and", "the", "filter", "given", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L218-L255
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
MessageHtmlParser.parse_thread
def parse_thread(self, participants, element_iter, require_flush): """ Parses a thread with appropriate CLI feedback. :param participants: The participants in this thread. :param element_iter: The XML iterator to parse the data from. :param require_flush: Whether the iterator ne...
python
def parse_thread(self, participants, element_iter, require_flush): """ Parses a thread with appropriate CLI feedback. :param participants: The participants in this thread. :param element_iter: The XML iterator to parse the data from. :param require_flush: Whether the iterator ne...
[ "def", "parse_thread", "(", "self", ",", "participants", ",", "element_iter", ",", "require_flush", ")", ":", "# Very rarely threads may lack information on who the", "# participants are. We will consider those threads corrupted", "# and skip them.", "participants_text", "=", "_tru...
Parses a thread with appropriate CLI feedback. :param participants: The participants in this thread. :param element_iter: The XML iterator to parse the data from. :param require_flush: Whether the iterator needs to be flushed if it is determined that the thread sho...
[ "Parses", "a", "thread", "with", "appropriate", "CLI", "feedback", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L275-L322
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
MessageHtmlParser._clear_output
def _clear_output(self): """ Clears progress output (if any) that was written to the screen. """ # If progress output was being written, clear it from the screen. if self.progress_output: sys.stderr.write("\r".ljust(self.last_line_len)) sys.stderr.write("\...
python
def _clear_output(self): """ Clears progress output (if any) that was written to the screen. """ # If progress output was being written, clear it from the screen. if self.progress_output: sys.stderr.write("\r".ljust(self.last_line_len)) sys.stderr.write("\...
[ "def", "_clear_output", "(", "self", ")", ":", "# If progress output was being written, clear it from the screen.", "if", "self", ".", "progress_output", ":", "sys", ".", "stderr", ".", "write", "(", "\"\\r\"", ".", "ljust", "(", "self", ".", "last_line_len", ")", ...
Clears progress output (if any) that was written to the screen.
[ "Clears", "progress", "output", "(", "if", "any", ")", "that", "was", "written", "to", "the", "screen", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L365-L373
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/parser.py
LegacyMessageHtmlParser.parse_impl
def parse_impl(self): """ Parses the HTML content as a stream. This is far less memory intensive than loading the entire HTML file into memory, like BeautifulSoup does. """ # Cast to str to ensure not unicode under Python 2, as the parser # doesn't like that. ...
python
def parse_impl(self): """ Parses the HTML content as a stream. This is far less memory intensive than loading the entire HTML file into memory, like BeautifulSoup does. """ # Cast to str to ensure not unicode under Python 2, as the parser # doesn't like that. ...
[ "def", "parse_impl", "(", "self", ")", ":", "# Cast to str to ensure not unicode under Python 2, as the parser", "# doesn't like that.", "parser", "=", "XMLParser", "(", "encoding", "=", "str", "(", "'UTF-8'", ")", ")", "element_iter", "=", "ET", ".", "iterparse", "("...
Parses the HTML content as a stream. This is far less memory intensive than loading the entire HTML file into memory, like BeautifulSoup does.
[ "Parses", "the", "HTML", "content", "as", "a", "stream", ".", "This", "is", "far", "less", "memory", "intensive", "than", "loading", "the", "entire", "HTML", "file", "into", "memory", "like", "BeautifulSoup", "does", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/parser.py#L385-L404
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/main.py
messages
def messages(path, thread, fmt, nocolor, timezones, utc, noprogress, resolve, directory): """ Conversion of Facebook chat history. """ with colorize_output(nocolor): try: chat_history = _process_history( path=path, thread=thread, timezones=timezones, u...
python
def messages(path, thread, fmt, nocolor, timezones, utc, noprogress, resolve, directory): """ Conversion of Facebook chat history. """ with colorize_output(nocolor): try: chat_history = _process_history( path=path, thread=thread, timezones=timezones, u...
[ "def", "messages", "(", "path", ",", "thread", ",", "fmt", ",", "nocolor", ",", "timezones", ",", "utc", ",", "noprogress", ",", "resolve", ",", "directory", ")", ":", "with", "colorize_output", "(", "nocolor", ")", ":", "try", ":", "chat_history", "=", ...
Conversion of Facebook chat history.
[ "Conversion", "of", "Facebook", "chat", "history", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/main.py#L174-L187
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/main.py
stats
def stats(path, fmt, nocolor, timezones, utc, noprogress, most_common, resolve, length): """Analysis of Facebook chat history.""" with colorize_output(nocolor): try: chat_history = _process_history( path=path, thread='', timezones=timezones, utc=utc, noprogres...
python
def stats(path, fmt, nocolor, timezones, utc, noprogress, most_common, resolve, length): """Analysis of Facebook chat history.""" with colorize_output(nocolor): try: chat_history = _process_history( path=path, thread='', timezones=timezones, utc=utc, noprogres...
[ "def", "stats", "(", "path", ",", "fmt", ",", "nocolor", ",", "timezones", ",", "utc", ",", "noprogress", ",", "most_common", ",", "resolve", ",", "length", ")", ":", "with", "colorize_output", "(", "nocolor", ")", ":", "try", ":", "chat_history", "=", ...
Analysis of Facebook chat history.
[ "Analysis", "of", "Facebook", "chat", "history", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/main.py#L203-L221
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/utils.py
set_stream_color
def set_stream_color(stream, disabled): """ Remember what our original streams were so that we can colorize them separately, which colorama doesn't seem to natively support. """ original_stdout = sys.stdout original_stderr = sys.stderr init(strip=disabled) if stream != original_std...
python
def set_stream_color(stream, disabled): """ Remember what our original streams were so that we can colorize them separately, which colorama doesn't seem to natively support. """ original_stdout = sys.stdout original_stderr = sys.stderr init(strip=disabled) if stream != original_std...
[ "def", "set_stream_color", "(", "stream", ",", "disabled", ")", ":", "original_stdout", "=", "sys", ".", "stdout", "original_stderr", "=", "sys", ".", "stderr", "init", "(", "strip", "=", "disabled", ")", "if", "stream", "!=", "original_stdout", ":", "sys", ...
Remember what our original streams were so that we can colorize them separately, which colorama doesn't seem to natively support.
[ "Remember", "what", "our", "original", "streams", "were", "so", "that", "we", "can", "colorize", "them", "separately", "which", "colorama", "doesn", "t", "seem", "to", "natively", "support", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/utils.py#L31-L47
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/name_resolver.py
FacebookNameResolver._manual_lookup
def _manual_lookup(self, facebook_id, facebook_id_string): """ People who we have not communicated with in a long time will not appear in the look-ahead cache that Facebook keeps. We must manually resolve them. :param facebook_id: Profile ID of the user to lookup. :retur...
python
def _manual_lookup(self, facebook_id, facebook_id_string): """ People who we have not communicated with in a long time will not appear in the look-ahead cache that Facebook keeps. We must manually resolve them. :param facebook_id: Profile ID of the user to lookup. :retur...
[ "def", "_manual_lookup", "(", "self", ",", "facebook_id", ",", "facebook_id_string", ")", ":", "resp", "=", "self", ".", "_session", ".", "get", "(", "'https://www.facebook.com/%s'", "%", "facebook_id", ",", "allow_redirects", "=", "True", ",", "timeout", "=", ...
People who we have not communicated with in a long time will not appear in the look-ahead cache that Facebook keeps. We must manually resolve them. :param facebook_id: Profile ID of the user to lookup. :return:
[ "People", "who", "we", "have", "not", "communicated", "with", "in", "a", "long", "time", "will", "not", "appear", "in", "the", "look", "-", "ahead", "cache", "that", "Facebook", "keeps", ".", "We", "must", "manually", "resolve", "them", "." ]
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/name_resolver.py#L125-L146
ownaginatious/fbchat-archive-parser
fbchat_archive_parser/time.py
parse_timestamp
def parse_timestamp(raw_timestamp, use_utc, hints): """ Facebook is highly inconsistent with their timezone formatting. Sometimes it's in UTC+/-HH:MM form, and other times its in the ambiguous PST, PDT. etc format. We have to handle the ambiguity by asking for cues from the user. raw_timestamp...
python
def parse_timestamp(raw_timestamp, use_utc, hints): """ Facebook is highly inconsistent with their timezone formatting. Sometimes it's in UTC+/-HH:MM form, and other times its in the ambiguous PST, PDT. etc format. We have to handle the ambiguity by asking for cues from the user. raw_timestamp...
[ "def", "parse_timestamp", "(", "raw_timestamp", ",", "use_utc", ",", "hints", ")", ":", "global", "FACEBOOK_TIMESTAMP_FORMATS", "timestamp_string", ",", "offset", "=", "raw_timestamp", ".", "rsplit", "(", "\" \"", ",", "1", ")", "if", "\"UTC+\"", "in", "offset",...
Facebook is highly inconsistent with their timezone formatting. Sometimes it's in UTC+/-HH:MM form, and other times its in the ambiguous PST, PDT. etc format. We have to handle the ambiguity by asking for cues from the user. raw_timestamp -- The timestamp string to parse and convert to UTC.
[ "Facebook", "is", "highly", "inconsistent", "with", "their", "timezone", "formatting", ".", "Sometimes", "it", "s", "in", "UTC", "+", "/", "-", "HH", ":", "MM", "form", "and", "other", "times", "its", "in", "the", "ambiguous", "PST", "PDT", ".", "etc", ...
train
https://github.com/ownaginatious/fbchat-archive-parser/blob/f1e66cea864f1c07b825fc036071f443693231d5/fbchat_archive_parser/time.py#L209-L261
cqparts/cqparts
src/cqparts/codec/__init__.py
register_exporter
def register_exporter(name, base_class): """ Register an exporter to use for a :class:`Part <cqparts.Part>`, :class:`Assembly <cqparts.Assembly>`, or both (with :class:`Component <cqparts.Component>`). Registration is necessary to use with :meth:`Component.exporter() <cqparts.Component.exporter...
python
def register_exporter(name, base_class): """ Register an exporter to use for a :class:`Part <cqparts.Part>`, :class:`Assembly <cqparts.Assembly>`, or both (with :class:`Component <cqparts.Component>`). Registration is necessary to use with :meth:`Component.exporter() <cqparts.Component.exporter...
[ "def", "register_exporter", "(", "name", ",", "base_class", ")", ":", "# Verify params", "if", "not", "isinstance", "(", "name", ",", "str", ")", "or", "(", "not", "name", ")", ":", "raise", "TypeError", "(", "\"invalid name: %r\"", "%", "name", ")", "if",...
Register an exporter to use for a :class:`Part <cqparts.Part>`, :class:`Assembly <cqparts.Assembly>`, or both (with :class:`Component <cqparts.Component>`). Registration is necessary to use with :meth:`Component.exporter() <cqparts.Component.exporter>`. :param name: name (or 'key') of exporter ...
[ "Register", "an", "exporter", "to", "use", "for", "a", ":", "class", ":", "Part", "<cqparts", ".", "Part", ">", ":", "class", ":", "Assembly", "<cqparts", ".", "Assembly", ">", "or", "both", "(", "with", ":", "class", ":", "Component", "<cqparts", ".",...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/codec/__init__.py#L17-L74
cqparts/cqparts
src/cqparts/codec/__init__.py
get_exporter
def get_exporter(obj, name): """ Get an exporter for the :param obj: object to export :type obj: :class:`Component <cqparts.Component>` :param name: registered name of exporter :type name: :class:`str` :return: an exporter instance of the given type :rtype: :class:`Exporter` :raises...
python
def get_exporter(obj, name): """ Get an exporter for the :param obj: object to export :type obj: :class:`Component <cqparts.Component>` :param name: registered name of exporter :type name: :class:`str` :return: an exporter instance of the given type :rtype: :class:`Exporter` :raises...
[ "def", "get_exporter", "(", "obj", ",", "name", ")", ":", "if", "name", "not", "in", "exporter_index", ":", "raise", "TypeError", "(", "(", "\"exporter type '%s' is not registered: \"", "%", "name", ")", "+", "(", "\"registered types: %r\"", "%", "sorted", "(", ...
Get an exporter for the :param obj: object to export :type obj: :class:`Component <cqparts.Component>` :param name: registered name of exporter :type name: :class:`str` :return: an exporter instance of the given type :rtype: :class:`Exporter` :raises TypeError: if exporter cannot be found
[ "Get", "an", "exporter", "for", "the" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/codec/__init__.py#L77-L101
cqparts/cqparts
src/cqparts/codec/__init__.py
get_importer
def get_importer(cls, name): """ Get an importer for the given registered type. :param cls: class to import :type cls: :class:`type` :param name: registered name of importer :type name: :class:`str` :return: an importer instance of the given type :rtype: :class:`Importer` :raises Ty...
python
def get_importer(cls, name): """ Get an importer for the given registered type. :param cls: class to import :type cls: :class:`type` :param name: registered name of importer :type name: :class:`str` :return: an importer instance of the given type :rtype: :class:`Importer` :raises Ty...
[ "def", "get_importer", "(", "cls", ",", "name", ")", ":", "if", "name", "not", "in", "importer_index", ":", "raise", "TypeError", "(", "(", "\"importer type '%s' is not registered: \"", "%", "name", ")", "+", "(", "\"registered types: %r\"", "%", "sorted", "(", ...
Get an importer for the given registered type. :param cls: class to import :type cls: :class:`type` :param name: registered name of importer :type name: :class:`str` :return: an importer instance of the given type :rtype: :class:`Importer` :raises TypeError: if importer cannot be found
[ "Get", "an", "importer", "for", "the", "given", "registered", "type", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/codec/__init__.py#L146-L170
cqparts/cqparts
src/cqparts_fasteners/catalogue/scripts/bunnings.py
BunningsProductSpider.parse
def parse(self, response): """Parse pagenated list of products""" # Check if page is out of range no_more_products = re.search( r'No matching products were found', response.css('div.paged-results').extract_first(), flags=re.I ) if no_more_prod...
python
def parse(self, response): """Parse pagenated list of products""" # Check if page is out of range no_more_products = re.search( r'No matching products were found', response.css('div.paged-results').extract_first(), flags=re.I ) if no_more_prod...
[ "def", "parse", "(", "self", ",", "response", ")", ":", "# Check if page is out of range", "no_more_products", "=", "re", ".", "search", "(", "r'No matching products were found'", ",", "response", ".", "css", "(", "'div.paged-results'", ")", ".", "extract_first", "(...
Parse pagenated list of products
[ "Parse", "pagenated", "list", "of", "products" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/catalogue/scripts/bunnings.py#L36-L58
cqparts/cqparts
src/cqparts_fasteners/catalogue/scripts/bunnings.py
BunningsProductSpider.parse_detail
def parse_detail(self, response): """Parse individual product's detail""" # Product Information (a start) product_data = { 'url': response.url, 'name': response.css('div.page-title h1::text').extract_first(), } # Inventory Number inventory_number ...
python
def parse_detail(self, response): """Parse individual product's detail""" # Product Information (a start) product_data = { 'url': response.url, 'name': response.css('div.page-title h1::text').extract_first(), } # Inventory Number inventory_number ...
[ "def", "parse_detail", "(", "self", ",", "response", ")", ":", "# Product Information (a start)", "product_data", "=", "{", "'url'", ":", "response", ".", "url", ",", "'name'", ":", "response", ".", "css", "(", "'div.page-title h1::text'", ")", ".", "extract_fir...
Parse individual product's detail
[ "Parse", "individual", "product", "s", "detail" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/catalogue/scripts/bunnings.py#L60-L86
cqparts/cqparts
src/cqparts/constraint/solver.py
solver
def solver(constraints, coord_sys=None): """ Solve constraints. Solutions pair :class:`Constraint <cqparts.constraint.Constraint>` instances with their suitable :class:`CoordSystem <cqparts.utils.geometry.CoordSystem>` world coordinates. :param constraints: constraints to solve :type constraint...
python
def solver(constraints, coord_sys=None): """ Solve constraints. Solutions pair :class:`Constraint <cqparts.constraint.Constraint>` instances with their suitable :class:`CoordSystem <cqparts.utils.geometry.CoordSystem>` world coordinates. :param constraints: constraints to solve :type constraint...
[ "def", "solver", "(", "constraints", ",", "coord_sys", "=", "None", ")", ":", "if", "coord_sys", "is", "None", ":", "coord_sys", "=", "CoordSystem", "(", ")", "# default", "# Verify list contains constraints", "for", "constraint", "in", "constraints", ":", "if",...
Solve constraints. Solutions pair :class:`Constraint <cqparts.constraint.Constraint>` instances with their suitable :class:`CoordSystem <cqparts.utils.geometry.CoordSystem>` world coordinates. :param constraints: constraints to solve :type constraints: iterable of :class:`Constraint <cqparts.constraint...
[ "Solve", "constraints", ".", "Solutions", "pair", ":", "class", ":", "Constraint", "<cqparts", ".", "constraint", ".", "Constraint", ">", "instances", "with", "their", "suitable", ":", "class", ":", "CoordSystem", "<cqparts", ".", "utils", ".", "geometry", "."...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/constraint/solver.py#L7-L72
cqparts/cqparts
src/cqparts_fasteners/utils/_casting.py
solid
def solid(solid_in): """ :return: cadquery.Solid instance """ if isinstance(solid_in, cadquery.Solid): return solid_in elif isinstance(solid_in, cadquery.CQ): return solid_in.val() raise CastingError( "Cannot cast object type of {!r} to a solid".format(solid_in) )
python
def solid(solid_in): """ :return: cadquery.Solid instance """ if isinstance(solid_in, cadquery.Solid): return solid_in elif isinstance(solid_in, cadquery.CQ): return solid_in.val() raise CastingError( "Cannot cast object type of {!r} to a solid".format(solid_in) )
[ "def", "solid", "(", "solid_in", ")", ":", "if", "isinstance", "(", "solid_in", ",", "cadquery", ".", "Solid", ")", ":", "return", "solid_in", "elif", "isinstance", "(", "solid_in", ",", "cadquery", ".", "CQ", ")", ":", "return", "solid_in", ".", "val", ...
:return: cadquery.Solid instance
[ ":", "return", ":", "cadquery", ".", "Solid", "instance" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/_casting.py#L17-L28
cqparts/cqparts
src/cqparts_fasteners/utils/_casting.py
vector
def vector(vect_in): """ :return: cadquery.Vector instance """ if isinstance(vect_in, cadquery.Vector): return vect_in elif isinstance(vect_in, (tuple, list)): return cadquery.Vector(vect_in) raise CastingError( "Cannot cast object type of {!r} to a vector".format(vect_i...
python
def vector(vect_in): """ :return: cadquery.Vector instance """ if isinstance(vect_in, cadquery.Vector): return vect_in elif isinstance(vect_in, (tuple, list)): return cadquery.Vector(vect_in) raise CastingError( "Cannot cast object type of {!r} to a vector".format(vect_i...
[ "def", "vector", "(", "vect_in", ")", ":", "if", "isinstance", "(", "vect_in", ",", "cadquery", ".", "Vector", ")", ":", "return", "vect_in", "elif", "isinstance", "(", "vect_in", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "cadquery", "."...
:return: cadquery.Vector instance
[ ":", "return", ":", "cadquery", ".", "Vector", "instance" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/_casting.py#L31-L42
cqparts/cqparts
src/cqparts_fasteners/solidtypes/fastener_heads/base.py
FastenerHead.make_cutter
def make_cutter(self): """ Create solid to subtract from material to make way for the fastener's head (just the head) """ return cadquery.Workplane('XY') \ .circle(self.access_diameter / 2) \ .extrude(self.access_height)
python
def make_cutter(self): """ Create solid to subtract from material to make way for the fastener's head (just the head) """ return cadquery.Workplane('XY') \ .circle(self.access_diameter / 2) \ .extrude(self.access_height)
[ "def", "make_cutter", "(", "self", ")", ":", "return", "cadquery", ".", "Workplane", "(", "'XY'", ")", ".", "circle", "(", "self", ".", "access_diameter", "/", "2", ")", ".", "extrude", "(", "self", ".", "access_height", ")" ]
Create solid to subtract from material to make way for the fastener's head (just the head)
[ "Create", "solid", "to", "subtract", "from", "material", "to", "make", "way", "for", "the", "fastener", "s", "head", "(", "just", "the", "head", ")" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/fastener_heads/base.py#L26-L33
cqparts/cqparts
deployment/make-setup.py
version_classifier
def version_classifier(version_str): """ Verify version consistency: version number must correspond to the correct "Development Status" classifier :raises: ValueError if error found, but ideally this function does nothing """ # cast version version = LooseVersion(version_str) for (test_...
python
def version_classifier(version_str): """ Verify version consistency: version number must correspond to the correct "Development Status" classifier :raises: ValueError if error found, but ideally this function does nothing """ # cast version version = LooseVersion(version_str) for (test_...
[ "def", "version_classifier", "(", "version_str", ")", ":", "# cast version", "version", "=", "LooseVersion", "(", "version_str", ")", "for", "(", "test_ver", ",", "classifier", ")", "in", "reversed", "(", "sorted", "(", "VERSION_CLASSIFIER_MAP", ",", "key", "=",...
Verify version consistency: version number must correspond to the correct "Development Status" classifier :raises: ValueError if error found, but ideally this function does nothing
[ "Verify", "version", "consistency", ":", "version", "number", "must", "correspond", "to", "the", "correct", "Development", "Status", "classifier", ":", "raises", ":", "ValueError", "if", "error", "found", "but", "ideally", "this", "function", "does", "nothing" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/deployment/make-setup.py#L121-L134
cqparts/cqparts
src/cqparts_motors/stepper.py
_Stator.mate_top
def mate_top(self): " top of the stator" return Mate(self, CoordSystem( origin=(0, 0, self.length/2), xDir=(0, 1, 0), normal=(0, 0, 1) ))
python
def mate_top(self): " top of the stator" return Mate(self, CoordSystem( origin=(0, 0, self.length/2), xDir=(0, 1, 0), normal=(0, 0, 1) ))
[ "def", "mate_top", "(", "self", ")", ":", "return", "Mate", "(", "self", ",", "CoordSystem", "(", "origin", "=", "(", "0", ",", "0", ",", "self", ".", "length", "/", "2", ")", ",", "xDir", "=", "(", "0", ",", "1", ",", "0", ")", ",", "normal"...
top of the stator
[ "top", "of", "the", "stator" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_motors/stepper.py#L71-L77
cqparts/cqparts
src/cqparts_motors/stepper.py
_Stator.mate_bottom
def mate_bottom(self): " bottom of the stator" return Mate(self, CoordSystem( origin=(0, 0, -self.length/2), xDir=(1, 0, 0), normal=(0, 0, -1) ))
python
def mate_bottom(self): " bottom of the stator" return Mate(self, CoordSystem( origin=(0, 0, -self.length/2), xDir=(1, 0, 0), normal=(0, 0, -1) ))
[ "def", "mate_bottom", "(", "self", ")", ":", "return", "Mate", "(", "self", ",", "CoordSystem", "(", "origin", "=", "(", "0", ",", "0", ",", "-", "self", ".", "length", "/", "2", ")", ",", "xDir", "=", "(", "1", ",", "0", ",", "0", ")", ",", ...
bottom of the stator
[ "bottom", "of", "the", "stator" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_motors/stepper.py#L80-L86
cqparts/cqparts
src/cqparts_motors/stepper.py
Stepper.mount_points
def mount_points(self): " return mount points" wp = cq.Workplane("XY") h = wp.rect(self.hole_spacing,self.hole_spacing ,forConstruction=True).vertices() return h.objects
python
def mount_points(self): " return mount points" wp = cq.Workplane("XY") h = wp.rect(self.hole_spacing,self.hole_spacing ,forConstruction=True).vertices() return h.objects
[ "def", "mount_points", "(", "self", ")", ":", "wp", "=", "cq", ".", "Workplane", "(", "\"XY\"", ")", "h", "=", "wp", ".", "rect", "(", "self", ".", "hole_spacing", ",", "self", ".", "hole_spacing", ",", "forConstruction", "=", "True", ")", ".", "vert...
return mount points
[ "return", "mount", "points" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_motors/stepper.py#L154-L159
cqparts/cqparts
src/cqparts_motors/stepper.py
Stepper.apply_cutout
def apply_cutout(self): " shaft cutout " stepper_shaft = self.components['shaft'] top = self.components['topcap'] local_obj = top.local_obj local_obj = local_obj.cut(stepper_shaft.get_cutout(clearance=0.5))
python
def apply_cutout(self): " shaft cutout " stepper_shaft = self.components['shaft'] top = self.components['topcap'] local_obj = top.local_obj local_obj = local_obj.cut(stepper_shaft.get_cutout(clearance=0.5))
[ "def", "apply_cutout", "(", "self", ")", ":", "stepper_shaft", "=", "self", ".", "components", "[", "'shaft'", "]", "top", "=", "self", ".", "components", "[", "'topcap'", "]", "local_obj", "=", "top", ".", "local_obj", "local_obj", "=", "local_obj", ".", ...
shaft cutout
[ "shaft", "cutout" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_motors/stepper.py#L200-L205
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.class_param_names
def class_param_names(cls, hidden=True): """ Return the names of all class parameters. :param hidden: if ``False``, excludes parameters with a ``_`` prefix. :type hidden: :class:`bool` :return: set of parameter names :rtype: :class:`set` """ param_names =...
python
def class_param_names(cls, hidden=True): """ Return the names of all class parameters. :param hidden: if ``False``, excludes parameters with a ``_`` prefix. :type hidden: :class:`bool` :return: set of parameter names :rtype: :class:`set` """ param_names =...
[ "def", "class_param_names", "(", "cls", ",", "hidden", "=", "True", ")", ":", "param_names", "=", "set", "(", "k", "for", "(", "k", ",", "v", ")", "in", "cls", ".", "__dict__", ".", "items", "(", ")", "if", "isinstance", "(", "v", ",", "Parameter",...
Return the names of all class parameters. :param hidden: if ``False``, excludes parameters with a ``_`` prefix. :type hidden: :class:`bool` :return: set of parameter names :rtype: :class:`set`
[ "Return", "the", "names", "of", "all", "class", "parameters", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L81-L100
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.class_params
def class_params(cls, hidden=True): """ Gets all class parameters, and their :class:`Parameter` instances. :return: dict of the form: ``{<name>: <Parameter instance>, ... }`` :rtype: :class:`dict` .. note:: The :class:`Parameter` instances returned do not have a va...
python
def class_params(cls, hidden=True): """ Gets all class parameters, and their :class:`Parameter` instances. :return: dict of the form: ``{<name>: <Parameter instance>, ... }`` :rtype: :class:`dict` .. note:: The :class:`Parameter` instances returned do not have a va...
[ "def", "class_params", "(", "cls", ",", "hidden", "=", "True", ")", ":", "param_names", "=", "cls", ".", "class_param_names", "(", "hidden", "=", "hidden", ")", "return", "dict", "(", "(", "name", ",", "getattr", "(", "cls", ",", "name", ")", ")", "f...
Gets all class parameters, and their :class:`Parameter` instances. :return: dict of the form: ``{<name>: <Parameter instance>, ... }`` :rtype: :class:`dict` .. note:: The :class:`Parameter` instances returned do not have a value, only a default value. To g...
[ "Gets", "all", "class", "parameters", "and", "their", ":", "class", ":", "Parameter", "instances", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L103-L123
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.params
def params(self, hidden=True): """ Gets all instance parameters, and their *cast* values. :return: dict of the form: ``{<name>: <value>, ... }`` :rtype: :class:`dict` """ param_names = self.class_param_names(hidden=hidden) return dict( (name, getattr(...
python
def params(self, hidden=True): """ Gets all instance parameters, and their *cast* values. :return: dict of the form: ``{<name>: <value>, ... }`` :rtype: :class:`dict` """ param_names = self.class_param_names(hidden=hidden) return dict( (name, getattr(...
[ "def", "params", "(", "self", ",", "hidden", "=", "True", ")", ":", "param_names", "=", "self", ".", "class_param_names", "(", "hidden", "=", "hidden", ")", "return", "dict", "(", "(", "name", ",", "getattr", "(", "self", ",", "name", ")", ")", "for"...
Gets all instance parameters, and their *cast* values. :return: dict of the form: ``{<name>: <value>, ... }`` :rtype: :class:`dict`
[ "Gets", "all", "instance", "parameters", "and", "their", "*", "cast", "*", "values", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L125-L136
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.serialize
def serialize(self): """ Encode a :class:`ParametricObject` instance to an object that can be encoded by the :mod:`json` module. :return: a dict of the format: :rtype: :class:`dict` :: { 'lib': { # library information 'n...
python
def serialize(self): """ Encode a :class:`ParametricObject` instance to an object that can be encoded by the :mod:`json` module. :return: a dict of the format: :rtype: :class:`dict` :: { 'lib': { # library information 'n...
[ "def", "serialize", "(", "self", ")", ":", "return", "{", "# Encode library information (future-proofing)", "'lib'", ":", "{", "'name'", ":", "'cqparts'", ",", "'version'", ":", "__version__", ",", "}", ",", "# class & name record, for automated import when decoding", "...
Encode a :class:`ParametricObject` instance to an object that can be encoded by the :mod:`json` module. :return: a dict of the format: :rtype: :class:`dict` :: { 'lib': { # library information 'name': 'cqparts', 'ver...
[ "Encode", "a", ":", "class", ":", "ParametricObject", "instance", "to", "an", "object", "that", "can", "be", "encoded", "by", "the", ":", "mod", ":", "json", "module", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L165-L232
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.serialize_parameters
def serialize_parameters(self): """ Get the parameter data in its serialized form. Data is serialized by each parameter's :meth:`Parameter.serialize` implementation. :return: serialized parameter data in the form: ``{<name>: <serial data>, ...}`` :rtype: :class:`dict` ...
python
def serialize_parameters(self): """ Get the parameter data in its serialized form. Data is serialized by each parameter's :meth:`Parameter.serialize` implementation. :return: serialized parameter data in the form: ``{<name>: <serial data>, ...}`` :rtype: :class:`dict` ...
[ "def", "serialize_parameters", "(", "self", ")", ":", "# Get parameter data", "class_params", "=", "self", ".", "class_params", "(", ")", "instance_params", "=", "self", ".", "params", "(", ")", "# Serialize each parameter", "serialized", "=", "{", "}", "for", "...
Get the parameter data in its serialized form. Data is serialized by each parameter's :meth:`Parameter.serialize` implementation. :return: serialized parameter data in the form: ``{<name>: <serial data>, ...}`` :rtype: :class:`dict`
[ "Get", "the", "parameter", "data", "in", "its", "serialized", "form", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L234-L255
cqparts/cqparts
src/cqparts/params/parametric_object.py
ParametricObject.deserialize
def deserialize(data): """ Create instance from serial data """ # Import module & get class try: module = import_module(data.get('class').get('module')) cls = getattr(module, data.get('class').get('name')) except ImportError: raise Impo...
python
def deserialize(data): """ Create instance from serial data """ # Import module & get class try: module = import_module(data.get('class').get('module')) cls = getattr(module, data.get('class').get('name')) except ImportError: raise Impo...
[ "def", "deserialize", "(", "data", ")", ":", "# Import module & get class", "try", ":", "module", "=", "import_module", "(", "data", ".", "get", "(", "'class'", ")", ".", "get", "(", "'module'", ")", ")", "cls", "=", "getattr", "(", "module", ",", "data"...
Create instance from serial data
[ "Create", "instance", "from", "serial", "data" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/params/parametric_object.py#L258-L282
cqparts/cqparts
src/cqparts/search.py
register
def register(**criteria): """ class decorator to add :class:`Part <cqparts.Part>` or :class:`Assembly <cqparts.Assembly>` to the ``cqparts`` search index: .. testcode:: import cqparts from cqparts.params import * # Created Part or Assembly @cqparts.search.register( ...
python
def register(**criteria): """ class decorator to add :class:`Part <cqparts.Part>` or :class:`Assembly <cqparts.Assembly>` to the ``cqparts`` search index: .. testcode:: import cqparts from cqparts.params import * # Created Part or Assembly @cqparts.search.register( ...
[ "def", "register", "(", "*", "*", "criteria", ")", ":", "def", "inner", "(", "cls", ")", ":", "# Add class references to search index", "class_list", ".", "add", "(", "cls", ")", "for", "(", "category", ",", "value", ")", "in", "criteria", ".", "items", ...
class decorator to add :class:`Part <cqparts.Part>` or :class:`Assembly <cqparts.Assembly>` to the ``cqparts`` search index: .. testcode:: import cqparts from cqparts.params import * # Created Part or Assembly @cqparts.search.register( type='motor', cur...
[ "class", "decorator", "to", "add", ":", "class", ":", "Part", "<cqparts", ".", "Part", ">", "or", ":", "class", ":", "Assembly", "<cqparts", ".", "Assembly", ">", "to", "the", "cqparts", "search", "index", ":" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/search.py#L29-L86
cqparts/cqparts
src/cqparts/search.py
search
def search(**criteria): """ Search registered *component* classes matching the given criteria. :param criteria: search criteria of the form: ``a='1', b='x'`` :return: parts registered with the given criteria :rtype: :class:`set` Will return an empty :class:`set` if nothing is found. :: ...
python
def search(**criteria): """ Search registered *component* classes matching the given criteria. :param criteria: search criteria of the form: ``a='1', b='x'`` :return: parts registered with the given criteria :rtype: :class:`set` Will return an empty :class:`set` if nothing is found. :: ...
[ "def", "search", "(", "*", "*", "criteria", ")", ":", "# Find all parts that match the given criteria", "results", "=", "copy", "(", "class_list", ")", "# start with full list", "for", "(", "category", ",", "value", ")", "in", "criteria", ".", "items", "(", ")",...
Search registered *component* classes matching the given criteria. :param criteria: search criteria of the form: ``a='1', b='x'`` :return: parts registered with the given criteria :rtype: :class:`set` Will return an empty :class:`set` if nothing is found. :: from cqparts.search import se...
[ "Search", "registered", "*", "component", "*", "classes", "matching", "the", "given", "criteria", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/search.py#L89-L117
cqparts/cqparts
src/cqparts/search.py
find
def find(**criteria): """ Find a single *component* class with the given criteria. Finds classes indexed with :meth:`register` :raises SearchMultipleFoundError: if more than one result found :raises SearchNoneFoundError: if nothing found :: from cqparts.search import find imp...
python
def find(**criteria): """ Find a single *component* class with the given criteria. Finds classes indexed with :meth:`register` :raises SearchMultipleFoundError: if more than one result found :raises SearchNoneFoundError: if nothing found :: from cqparts.search import find imp...
[ "def", "find", "(", "*", "*", "criteria", ")", ":", "# Find all parts that match the given criteria", "results", "=", "search", "(", "*", "*", "criteria", ")", "# error cases", "if", "len", "(", "results", ")", ">", "1", ":", "raise", "SearchMultipleFoundError",...
Find a single *component* class with the given criteria. Finds classes indexed with :meth:`register` :raises SearchMultipleFoundError: if more than one result found :raises SearchNoneFoundError: if nothing found :: from cqparts.search import find import cqparts_motors # example of a...
[ "Find", "a", "single", "*", "component", "*", "class", "with", "the", "given", "criteria", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/search.py#L120-L148
cqparts/cqparts
src/cqparts/search.py
common_criteria
def common_criteria(**common): """ Wrap a function to always call with the given ``common`` named parameters. :property common: criteria common to your function call :return: decorator function :rtype: :class:`function` .. doctest:: >>> import cqparts >>> from cqparts.search i...
python
def common_criteria(**common): """ Wrap a function to always call with the given ``common`` named parameters. :property common: criteria common to your function call :return: decorator function :rtype: :class:`function` .. doctest:: >>> import cqparts >>> from cqparts.search i...
[ "def", "common_criteria", "(", "*", "*", "common", ")", ":", "def", "decorator", "(", "func", ")", ":", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "merged_kwargs", "=", "copy", "(", "common", ")", "merged_kwargs", ".", "upda...
Wrap a function to always call with the given ``common`` named parameters. :property common: criteria common to your function call :return: decorator function :rtype: :class:`function` .. doctest:: >>> import cqparts >>> from cqparts.search import register, search, find >>> fr...
[ "Wrap", "a", "function", "to", "always", "call", "with", "the", "given", "common", "named", "parameters", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/search.py#L151-L220
cqparts/cqparts
src/cqparts/utils/geometry.py
merge_boundboxes
def merge_boundboxes(*bb_list): """ Combine bounding boxes to result in a single BoundBox that encloses all of them. :param bb_list: List of bounding boxes :type bb_list: :class:`list` of :class:`cadquery.BoundBox` """ # Verify types if not all(isinstance(x, cadquery.BoundBox) for x in ...
python
def merge_boundboxes(*bb_list): """ Combine bounding boxes to result in a single BoundBox that encloses all of them. :param bb_list: List of bounding boxes :type bb_list: :class:`list` of :class:`cadquery.BoundBox` """ # Verify types if not all(isinstance(x, cadquery.BoundBox) for x in ...
[ "def", "merge_boundboxes", "(", "*", "bb_list", ")", ":", "# Verify types", "if", "not", "all", "(", "isinstance", "(", "x", ",", "cadquery", ".", "BoundBox", ")", "for", "x", "in", "bb_list", ")", ":", "raise", "TypeError", "(", "\"parameters must be cadque...
Combine bounding boxes to result in a single BoundBox that encloses all of them. :param bb_list: List of bounding boxes :type bb_list: :class:`list` of :class:`cadquery.BoundBox`
[ "Combine", "bounding", "boxes", "to", "result", "in", "a", "single", "BoundBox", "that", "encloses", "all", "of", "them", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/geometry.py#L9-L39
cqparts/cqparts
src/cqparts/utils/geometry.py
CoordSystem.from_plane
def from_plane(cls, plane): """ :param plane: cadquery plane instance to base coordinate system on :type plane: :class:`cadquery.Plane` :return: duplicate of the given plane, in this class :rtype: :class:`CoordSystem` usage example: .. doctest:: >>>...
python
def from_plane(cls, plane): """ :param plane: cadquery plane instance to base coordinate system on :type plane: :class:`cadquery.Plane` :return: duplicate of the given plane, in this class :rtype: :class:`CoordSystem` usage example: .. doctest:: >>>...
[ "def", "from_plane", "(", "cls", ",", "plane", ")", ":", "return", "cls", "(", "origin", "=", "plane", ".", "origin", ".", "toTuple", "(", ")", ",", "xDir", "=", "plane", ".", "xDir", ".", "toTuple", "(", ")", ",", "normal", "=", "plane", ".", "z...
:param plane: cadquery plane instance to base coordinate system on :type plane: :class:`cadquery.Plane` :return: duplicate of the given plane, in this class :rtype: :class:`CoordSystem` usage example: .. doctest:: >>> import cadquery >>> from cqparts.ut...
[ ":", "param", "plane", ":", "cadquery", "plane", "instance", "to", "base", "coordinate", "system", "on", ":", "type", "plane", ":", ":", "class", ":", "cadquery", ".", "Plane", ":", "return", ":", "duplicate", "of", "the", "given", "plane", "in", "this",...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/geometry.py#L53-L80
cqparts/cqparts
src/cqparts/utils/geometry.py
CoordSystem.from_transform
def from_transform(cls, matrix): r""" :param matrix: 4x4 3d affine transform matrix :type matrix: :class:`FreeCAD.Matrix` :return: a unit, zero offset coordinate system transformed by the given matrix :rtype: :class:`CoordSystem` Individual rotation & translation matrici...
python
def from_transform(cls, matrix): r""" :param matrix: 4x4 3d affine transform matrix :type matrix: :class:`FreeCAD.Matrix` :return: a unit, zero offset coordinate system transformed by the given matrix :rtype: :class:`CoordSystem` Individual rotation & translation matrici...
[ "def", "from_transform", "(", "cls", ",", "matrix", ")", ":", "# Create reference points at origin", "offset", "=", "FreeCAD", ".", "Vector", "(", "0", ",", "0", ",", "0", ")", "x_vertex", "=", "FreeCAD", ".", "Vector", "(", "1", ",", "0", ",", "0", ")...
r""" :param matrix: 4x4 3d affine transform matrix :type matrix: :class:`FreeCAD.Matrix` :return: a unit, zero offset coordinate system transformed by the given matrix :rtype: :class:`CoordSystem` Individual rotation & translation matricies are: .. math:: R...
[ "r", ":", "param", "matrix", ":", "4x4", "3d", "affine", "transform", "matrix", ":", "type", "matrix", ":", ":", "class", ":", "FreeCAD", ".", "Matrix", ":", "return", ":", "a", "unit", "zero", "offset", "coordinate", "system", "transformed", "by", "the"...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/geometry.py#L83-L163
cqparts/cqparts
src/cqparts/utils/geometry.py
CoordSystem.random
def random(cls, span=1, seed=None): """ Creates a randomized coordinate system. Useful for confirming that an *assembly* does not rely on its origin coordinate system to remain intact. For example, the :class:`CoordSysIndicator` *assembly* aligns 3 boxes along each of t...
python
def random(cls, span=1, seed=None): """ Creates a randomized coordinate system. Useful for confirming that an *assembly* does not rely on its origin coordinate system to remain intact. For example, the :class:`CoordSysIndicator` *assembly* aligns 3 boxes along each of t...
[ "def", "random", "(", "cls", ",", "span", "=", "1", ",", "seed", "=", "None", ")", ":", "if", "seed", "is", "not", "None", ":", "random", ".", "seed", "(", "seed", ")", "def", "rand_vect", "(", "min", ",", "max", ")", ":", "return", "(", "rando...
Creates a randomized coordinate system. Useful for confirming that an *assembly* does not rely on its origin coordinate system to remain intact. For example, the :class:`CoordSysIndicator` *assembly* aligns 3 boxes along each of the :math:`XYZ` axes. Positioning it randomly by ...
[ "Creates", "a", "randomized", "coordinate", "system", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/geometry.py#L166-L216
cqparts/cqparts
src/cqparts/utils/wrappers.py
as_part
def as_part(func): """ Converts a function to a :class:`Part <cqparts.Part>` instance. So the conventionally defined *part*:: import cadquery from cqparts import Part from cqparts.params import Float class Box(Part): x = Float(1) y = Float(2) ...
python
def as_part(func): """ Converts a function to a :class:`Part <cqparts.Part>` instance. So the conventionally defined *part*:: import cadquery from cqparts import Part from cqparts.params import Float class Box(Part): x = Float(1) y = Float(2) ...
[ "def", "as_part", "(", "func", ")", ":", "from", ".", ".", "import", "Part", "def", "inner", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "part_class", "=", "type", "(", "func", ".", "__name__", ",", "(", "Part", ",", ")", ",", "{", "'m...
Converts a function to a :class:`Part <cqparts.Part>` instance. So the conventionally defined *part*:: import cadquery from cqparts import Part from cqparts.params import Float class Box(Part): x = Float(1) y = Float(2) z = Float(4) ...
[ "Converts", "a", "function", "to", "a", ":", "class", ":", "Part", "<cqparts", ".", "Part", ">", "instance", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/wrappers.py#L2-L42
cqparts/cqparts
src/cqparts/catalogue/json.py
JSONCatalogue.find
def find(self, *args, **kwargs): """ Performs the same action as :meth:`search` but asserts a single result. :return: :raises SearchNoneFoundError: if nothing was found :raises SearchMultipleFoundError: if more than one result is found """ result = self.search(*...
python
def find(self, *args, **kwargs): """ Performs the same action as :meth:`search` but asserts a single result. :return: :raises SearchNoneFoundError: if nothing was found :raises SearchMultipleFoundError: if more than one result is found """ result = self.search(*...
[ "def", "find", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "search", "(", "*", "args", ",", "*", "*", "kwargs", ")", "if", "len", "(", "result", ")", "==", "0", ":", "raise", "SearchNoneFoundError...
Performs the same action as :meth:`search` but asserts a single result. :return: :raises SearchNoneFoundError: if nothing was found :raises SearchMultipleFoundError: if more than one result is found
[ "Performs", "the", "same", "action", "as", ":", "meth", ":", "search", "but", "asserts", "a", "single", "result", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/catalogue/json.py#L109-L125
cqparts/cqparts
src/cqparts/catalogue/json.py
JSONCatalogue.add
def add(self, id, obj, criteria={}, force=False, _check_id=True): """ Add a :class:`Component <cqparts.Component>` instance to the database. :param id: unique id of entry, can be anything :type id: :class:`str` :param obj: component to be serialized, then added to the catalogue ...
python
def add(self, id, obj, criteria={}, force=False, _check_id=True): """ Add a :class:`Component <cqparts.Component>` instance to the database. :param id: unique id of entry, can be anything :type id: :class:`str` :param obj: component to be serialized, then added to the catalogue ...
[ "def", "add", "(", "self", ",", "id", ",", "obj", ",", "criteria", "=", "{", "}", ",", "force", "=", "False", ",", "_check_id", "=", "True", ")", ":", "# Verify component", "if", "not", "isinstance", "(", "obj", ",", "Component", ")", ":", "raise", ...
Add a :class:`Component <cqparts.Component>` instance to the database. :param id: unique id of entry, can be anything :type id: :class:`str` :param obj: component to be serialized, then added to the catalogue :type obj: :class:`Component <cqparts.Component>` :param criteria: arb...
[ "Add", "a", ":", "class", ":", "Component", "<cqparts", ".", "Component", ">", "instance", "to", "the", "database", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/catalogue/json.py#L128-L174
cqparts/cqparts
src/cqparts/catalogue/json.py
JSONCatalogue.get
def get(self, *args, **kwargs): """ Combination of :meth:`find` and :meth:`deserialize_item`; the result from :meth:`find` is deserialized and returned. Input is a :mod:`tinydb` query. :return: deserialized object instance :rtype: :class:`Component <cqparts.Component>` ...
python
def get(self, *args, **kwargs): """ Combination of :meth:`find` and :meth:`deserialize_item`; the result from :meth:`find` is deserialized and returned. Input is a :mod:`tinydb` query. :return: deserialized object instance :rtype: :class:`Component <cqparts.Component>` ...
[ "def", "get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "result", "=", "self", ".", "find", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "deserialize_item", "(", "result", ")" ]
Combination of :meth:`find` and :meth:`deserialize_item`; the result from :meth:`find` is deserialized and returned. Input is a :mod:`tinydb` query. :return: deserialized object instance :rtype: :class:`Component <cqparts.Component>`
[ "Combination", "of", ":", "meth", ":", "find", "and", ":", "meth", ":", "deserialize_item", ";", "the", "result", "from", ":", "meth", ":", "find", "is", "deserialized", "and", "returned", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/catalogue/json.py#L199-L210
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEffect.start_point
def start_point(self): """ Start vertex of effect :return: vertex (as vector) :rtype: :class:`cadquery.Vector` """ edge = self.result.wire().val().Edges()[0] return edge.Vertices()[0].Center()
python
def start_point(self): """ Start vertex of effect :return: vertex (as vector) :rtype: :class:`cadquery.Vector` """ edge = self.result.wire().val().Edges()[0] return edge.Vertices()[0].Center()
[ "def", "start_point", "(", "self", ")", ":", "edge", "=", "self", ".", "result", ".", "wire", "(", ")", ".", "val", "(", ")", ".", "Edges", "(", ")", "[", "0", "]", "return", "edge", ".", "Vertices", "(", ")", "[", "0", "]", ".", "Center", "(...
Start vertex of effect :return: vertex (as vector) :rtype: :class:`cadquery.Vector`
[ "Start", "vertex", "of", "effect" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L40-L48
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEffect.start_coordsys
def start_coordsys(self): """ Coordinate system at start of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's start point. :return: coordinate system at start of effect :rtype: :class:`CoordSys` """ ...
python
def start_coordsys(self): """ Coordinate system at start of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's start point. :return: coordinate system at start of effect :rtype: :class:`CoordSys` """ ...
[ "def", "start_coordsys", "(", "self", ")", ":", "coordsys", "=", "copy", "(", "self", ".", "location", ")", "coordsys", ".", "origin", "=", "self", ".", "start_point", "return", "coordsys" ]
Coordinate system at start of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's start point. :return: coordinate system at start of effect :rtype: :class:`CoordSys`
[ "Coordinate", "system", "at", "start", "of", "effect", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L51-L63
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEffect.end_coordsys
def end_coordsys(self): """ Coordinate system at end of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's end point. :return: coordinate system at end of effect :rtype: :class:`CoordSys` """ ...
python
def end_coordsys(self): """ Coordinate system at end of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's end point. :return: coordinate system at end of effect :rtype: :class:`CoordSys` """ ...
[ "def", "end_coordsys", "(", "self", ")", ":", "coordsys", "=", "copy", "(", "self", ".", "location", ")", "coordsys", ".", "origin", "=", "self", ".", "end_point", "return", "coordsys" ]
Coordinate system at end of effect. All axes are parallel to the original vector evaluation location, with the origin moved to this effect's end point. :return: coordinate system at end of effect :rtype: :class:`CoordSys`
[ "Coordinate", "system", "at", "end", "of", "effect", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L77-L89
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEffect.origin_displacement
def origin_displacement(self): """ planar distance of start point from self.location along :math:`-Z` axis """ return self.start_point.sub(self.location.origin).dot(-self.location.zDir)
python
def origin_displacement(self): """ planar distance of start point from self.location along :math:`-Z` axis """ return self.start_point.sub(self.location.origin).dot(-self.location.zDir)
[ "def", "origin_displacement", "(", "self", ")", ":", "return", "self", ".", "start_point", ".", "sub", "(", "self", ".", "location", ".", "origin", ")", ".", "dot", "(", "-", "self", ".", "location", ".", "zDir", ")" ]
planar distance of start point from self.location along :math:`-Z` axis
[ "planar", "distance", "of", "start", "point", "from", "self", ".", "location", "along", ":", "math", ":", "-", "Z", "axis" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L92-L96
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEvaluator.max_effect_length
def max_effect_length(self): """ :return: The longest possible effect vector length. :rtype: float In other words, the *radius* of a sphere: - who's center is at ``start``. - all ``parts`` are contained within the sphere. """ # Method: using each...
python
def max_effect_length(self): """ :return: The longest possible effect vector length. :rtype: float In other words, the *radius* of a sphere: - who's center is at ``start``. - all ``parts`` are contained within the sphere. """ # Method: using each...
[ "def", "max_effect_length", "(", "self", ")", ":", "# Method: using each solid's bounding box:", "# - get vector from start to bounding box center", "# - get vector from bounding box center to any corner", "# - add the length of both vectors", "# - return the maximum of these from all so...
:return: The longest possible effect vector length. :rtype: float In other words, the *radius* of a sphere: - who's center is at ``start``. - all ``parts`` are contained within the sphere.
[ ":", "return", ":", "The", "longest", "possible", "effect", "vector", "length", ".", ":", "rtype", ":", "float" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L206-L230
cqparts/cqparts
src/cqparts_fasteners/utils/evaluator.py
VectorEvaluator.perform_evaluation
def perform_evaluation(self): """ Determine which parts lie along the given vector, and what length :return: effects on the given parts (in order of the distance from the start point) :rtype: list(:class:`VectorEffect`) """ # Create effect vector (with m...
python
def perform_evaluation(self): """ Determine which parts lie along the given vector, and what length :return: effects on the given parts (in order of the distance from the start point) :rtype: list(:class:`VectorEffect`) """ # Create effect vector (with m...
[ "def", "perform_evaluation", "(", "self", ")", ":", "# Create effect vector (with max length)", "if", "not", "self", ".", "max_effect_length", ":", "# no effect is possible, return an empty list", "return", "[", "]", "edge", "=", "cadquery", ".", "Edge", ".", "makeLine"...
Determine which parts lie along the given vector, and what length :return: effects on the given parts (in order of the distance from the start point) :rtype: list(:class:`VectorEffect`)
[ "Determine", "which", "parts", "lie", "along", "the", "given", "vector", "and", "what", "length" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/utils/evaluator.py#L232-L263
cqparts/cqparts
src/cqparts/display/__init__.py
display
def display(component, **kwargs): """ Display the given component based on the environment it's run from. See :class:`DisplayEnvironment <cqparts.display.environment.DisplayEnvironment>` documentation for more details. :param component: component to display :type component: :class:`Component <c...
python
def display(component, **kwargs): """ Display the given component based on the environment it's run from. See :class:`DisplayEnvironment <cqparts.display.environment.DisplayEnvironment>` documentation for more details. :param component: component to display :type component: :class:`Component <c...
[ "def", "display", "(", "component", ",", "*", "*", "kwargs", ")", ":", "disp_env", "=", "get_display_environment", "(", ")", "if", "disp_env", "is", "None", ":", "raise", "LookupError", "(", "'valid display environment could not be found'", ")", "disp_env", ".", ...
Display the given component based on the environment it's run from. See :class:`DisplayEnvironment <cqparts.display.environment.DisplayEnvironment>` documentation for more details. :param component: component to display :type component: :class:`Component <cqparts.Component>` Additional parameters ...
[ "Display", "the", "given", "component", "based", "on", "the", "environment", "it", "s", "run", "from", ".", "See", ":", "class", ":", "DisplayEnvironment", "<cqparts", ".", "display", ".", "environment", ".", "DisplayEnvironment", ">", "documentation", "for", ...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/display/__init__.py#L66-L83
cqparts/cqparts
src/cqparts/display/material.py
render_props
def render_props(**kwargs): """ Return a valid property for cleaner referencing in :class:`Part <cqparts.Part>` child classes. :param template: name of template to use (any of ``TEMPLATE.keys()``) :type template: :class:`str` :param doc: description of parameter for sphinx docs :type doc: :...
python
def render_props(**kwargs): """ Return a valid property for cleaner referencing in :class:`Part <cqparts.Part>` child classes. :param template: name of template to use (any of ``TEMPLATE.keys()``) :type template: :class:`str` :param doc: description of parameter for sphinx docs :type doc: :...
[ "def", "render_props", "(", "*", "*", "kwargs", ")", ":", "# Pop named args", "template", "=", "kwargs", ".", "pop", "(", "'template'", ",", "'default'", ")", "doc", "=", "kwargs", ".", "pop", "(", "'doc'", ",", "\"render properties\"", ")", "params", "=",...
Return a valid property for cleaner referencing in :class:`Part <cqparts.Part>` child classes. :param template: name of template to use (any of ``TEMPLATE.keys()``) :type template: :class:`str` :param doc: description of parameter for sphinx docs :type doc: :class:`str` :return: render propert...
[ "Return", "a", "valid", "property", "for", "cleaner", "referencing", "in", ":", "class", ":", "Part", "<cqparts", ".", "Part", ">", "child", "classes", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/display/material.py#L191-L233
cqparts/cqparts
src/cqparts_fasteners/solidtypes/screw_drives/base.py
ScrewDrive.apply
def apply(self, workplane, world_coords=CoordSystem()): """ Application of screwdrive indentation into a workplane (centred on the given world coordinates). :param workplane: workplane with solid to alter :type workplane: :class:`cadquery.Workplane` :param world_coords: ...
python
def apply(self, workplane, world_coords=CoordSystem()): """ Application of screwdrive indentation into a workplane (centred on the given world coordinates). :param workplane: workplane with solid to alter :type workplane: :class:`cadquery.Workplane` :param world_coords: ...
[ "def", "apply", "(", "self", ",", "workplane", ",", "world_coords", "=", "CoordSystem", "(", ")", ")", ":", "self", ".", "world_coords", "=", "world_coords", "return", "workplane", ".", "cut", "(", "self", ".", "world_obj", ")" ]
Application of screwdrive indentation into a workplane (centred on the given world coordinates). :param workplane: workplane with solid to alter :type workplane: :class:`cadquery.Workplane` :param world_coords: coorindate system relative to ``workplane`` to move ...
[ "Application", "of", "screwdrive", "indentation", "into", "a", "workplane", "(", "centred", "on", "the", "given", "world", "coordinates", ")", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/screw_drives/base.py#L28-L41
cqparts/cqparts
src/cqparts/utils/sphinx.py
add_parametric_object_params
def add_parametric_object_params(prepend=False, hide_private=True): """ Add :class:`ParametricObject <cqparts.params.ParametricObject>` parameters in a list to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py`` file:: from cqparts.utils...
python
def add_parametric_object_params(prepend=False, hide_private=True): """ Add :class:`ParametricObject <cqparts.params.ParametricObject>` parameters in a list to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py`` file:: from cqparts.utils...
[ "def", "add_parametric_object_params", "(", "prepend", "=", "False", ",", "hide_private", "=", "True", ")", ":", "from", ".", ".", "params", "import", "ParametricObject", "def", "param_lines", "(", "app", ",", "obj", ")", ":", "params", "=", "obj", ".", "c...
Add :class:`ParametricObject <cqparts.params.ParametricObject>` parameters in a list to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py`` file:: from cqparts.utils.sphinx import add_parametric_object_params def setup(app): ...
[ "Add", ":", "class", ":", "ParametricObject", "<cqparts", ".", "params", ".", "ParametricObject", ">", "parameters", "in", "a", "list", "to", "the", "*", "docstring", "*", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/sphinx.py#L47-L109
cqparts/cqparts
src/cqparts/utils/sphinx.py
add_search_index_criteria
def add_search_index_criteria(prepend=False): """ Add the search criteria used when calling :meth:`register() <cqparts.search.register>` on a :class:`Component <cqparts.Component>` as a table to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py``...
python
def add_search_index_criteria(prepend=False): """ Add the search criteria used when calling :meth:`register() <cqparts.search.register>` on a :class:`Component <cqparts.Component>` as a table to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py``...
[ "def", "add_search_index_criteria", "(", "prepend", "=", "False", ")", ":", "from", ".", ".", "search", "import", "class_criteria", "from", ".", ".", "import", "Component", "COLUMN_INFO", "=", "[", "# (<title>, <width>, <method>),", "(", "'Key'", ",", "50", ",",...
Add the search criteria used when calling :meth:`register() <cqparts.search.register>` on a :class:`Component <cqparts.Component>` as a table to the *docstring*. This is only intended to be used with *sphinx autodoc*. In your *sphinx* ``config.py`` file:: from cqparts.utils.sphinx import add_sear...
[ "Add", "the", "search", "criteria", "used", "when", "calling", ":", "meth", ":", "register", "()", "<cqparts", ".", "search", ".", "register", ">", "on", "a", ":", "class", ":", "Component", "<cqparts", ".", "Component", ">", "as", "a", "table", "to", ...
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/sphinx.py#L112-L193
cqparts/cqparts
src/cqparts/utils/sphinx.py
skip_class_parameters
def skip_class_parameters(): """ Can be used with :meth:`add_parametric_object_params`, this removes duplicate variables cluttering the sphinx docs. This is only intended to be used with *sphinx autodoc* In your *sphinx* ``config.py`` file:: from cqparts.utils.sphinx import skip_class_par...
python
def skip_class_parameters(): """ Can be used with :meth:`add_parametric_object_params`, this removes duplicate variables cluttering the sphinx docs. This is only intended to be used with *sphinx autodoc* In your *sphinx* ``config.py`` file:: from cqparts.utils.sphinx import skip_class_par...
[ "def", "skip_class_parameters", "(", ")", ":", "from", ".", ".", "params", "import", "Parameter", "def", "callback", "(", "app", ",", "what", ",", "name", ",", "obj", ",", "skip", ",", "options", ")", ":", "if", "(", "what", "==", "'class'", ")", "an...
Can be used with :meth:`add_parametric_object_params`, this removes duplicate variables cluttering the sphinx docs. This is only intended to be used with *sphinx autodoc* In your *sphinx* ``config.py`` file:: from cqparts.utils.sphinx import skip_class_parameters def setup(app): ...
[ "Can", "be", "used", "with", ":", "meth", ":", "add_parametric_object_params", "this", "removes", "duplicate", "variables", "cluttering", "the", "sphinx", "docs", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/sphinx.py#L197-L218
cqparts/cqparts
src/cqparts/utils/misc.py
indicate_last
def indicate_last(items): """ iterate through list and indicate which item is the last, intended to assist tree displays of hierarchical content. :return: yielding (<bool>, <item>) where bool is True only on last entry :rtype: generator """ last_index = len(items) - 1 for (i, item) in e...
python
def indicate_last(items): """ iterate through list and indicate which item is the last, intended to assist tree displays of hierarchical content. :return: yielding (<bool>, <item>) where bool is True only on last entry :rtype: generator """ last_index = len(items) - 1 for (i, item) in e...
[ "def", "indicate_last", "(", "items", ")", ":", "last_index", "=", "len", "(", "items", ")", "-", "1", "for", "(", "i", ",", "item", ")", "in", "enumerate", "(", "items", ")", ":", "yield", "(", "i", "==", "last_index", ",", "item", ")" ]
iterate through list and indicate which item is the last, intended to assist tree displays of hierarchical content. :return: yielding (<bool>, <item>) where bool is True only on last entry :rtype: generator
[ "iterate", "through", "list", "and", "indicate", "which", "item", "is", "the", "last", "intended", "to", "assist", "tree", "displays", "of", "hierarchical", "content", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/misc.py#L48-L58
cqparts/cqparts
src/cqparts/utils/misc.py
working_dir
def working_dir(path): """ Change working directory within a context:: >>> import os >>> from cqparts.utils import working_dir >>> print(os.getcwd()) /home/myuser/temp >>> with working_dir('..'): ... print(os.getcwd()) ... /home/myuser ...
python
def working_dir(path): """ Change working directory within a context:: >>> import os >>> from cqparts.utils import working_dir >>> print(os.getcwd()) /home/myuser/temp >>> with working_dir('..'): ... print(os.getcwd()) ... /home/myuser ...
[ "def", "working_dir", "(", "path", ")", ":", "initial_path", "=", "os", ".", "getcwd", "(", ")", "os", ".", "chdir", "(", "path", ")", "yield", "os", ".", "chdir", "(", "initial_path", ")" ]
Change working directory within a context:: >>> import os >>> from cqparts.utils import working_dir >>> print(os.getcwd()) /home/myuser/temp >>> with working_dir('..'): ... print(os.getcwd()) ... /home/myuser :param path: working path to use wh...
[ "Change", "working", "directory", "within", "a", "context", "::" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts/utils/misc.py#L62-L83
cqparts/cqparts
src/cqparts_fasteners/solidtypes/threads/base.py
profile_to_cross_section
def profile_to_cross_section(profile, lefthand=False, start_count=1, min_vertices=20): r""" Converts a thread profile to it's equivalent cross-section. **Profile:** The thread profile contains a single wire along the XZ plane (note: wire will be projected onto the XZ plane; Y-coords will be ignore...
python
def profile_to_cross_section(profile, lefthand=False, start_count=1, min_vertices=20): r""" Converts a thread profile to it's equivalent cross-section. **Profile:** The thread profile contains a single wire along the XZ plane (note: wire will be projected onto the XZ plane; Y-coords will be ignore...
[ "def", "profile_to_cross_section", "(", "profile", ",", "lefthand", "=", "False", ",", "start_count", "=", "1", ",", "min_vertices", "=", "20", ")", ":", "# verify parameter(s)", "if", "not", "isinstance", "(", "profile", ",", "cadquery", ".", "Workplane", ")"...
r""" Converts a thread profile to it's equivalent cross-section. **Profile:** The thread profile contains a single wire along the XZ plane (note: wire will be projected onto the XZ plane; Y-coords will be ignored). The profile is expected to be of 1 thread rotation, so it's height (along the Z...
[ "r", "Converts", "a", "thread", "profile", "to", "it", "s", "equivalent", "cross", "-", "section", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/threads/base.py#L26-L204
cqparts/cqparts
src/cqparts_fasteners/solidtypes/threads/base.py
Thread.profile
def profile(self): """ Buffered result of :meth:`build_profile` """ if self._profile is None: self._profile = self.build_profile() return self._profile
python
def profile(self): """ Buffered result of :meth:`build_profile` """ if self._profile is None: self._profile = self.build_profile() return self._profile
[ "def", "profile", "(", "self", ")", ":", "if", "self", ".", "_profile", "is", "None", ":", "self", ".", "_profile", "=", "self", ".", "build_profile", "(", ")", "return", "self", ".", "_profile" ]
Buffered result of :meth:`build_profile`
[ "Buffered", "result", "of", ":", "meth", ":", "build_profile" ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/threads/base.py#L298-L304
cqparts/cqparts
src/cqparts_fasteners/solidtypes/threads/base.py
Thread.get_radii
def get_radii(self): """ Get the inner and outer radii of the thread. :return: (<inner radius>, <outer radius>) :rtype: :class:`tuple` .. note:: Ideally this method is overridden in inheriting classes to mathematically determine the radii. ...
python
def get_radii(self): """ Get the inner and outer radii of the thread. :return: (<inner radius>, <outer radius>) :rtype: :class:`tuple` .. note:: Ideally this method is overridden in inheriting classes to mathematically determine the radii. ...
[ "def", "get_radii", "(", "self", ")", ":", "bb", "=", "self", ".", "profile", ".", "val", "(", ")", ".", "BoundingBox", "(", ")", "return", "(", "bb", ".", "xmin", ",", "bb", ".", "xmax", ")" ]
Get the inner and outer radii of the thread. :return: (<inner radius>, <outer radius>) :rtype: :class:`tuple` .. note:: Ideally this method is overridden in inheriting classes to mathematically determine the radii. Default action is to generate the profile...
[ "Get", "the", "inner", "and", "outer", "radii", "of", "the", "thread", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/threads/base.py#L306-L323
cqparts/cqparts
src/cqparts_fasteners/solidtypes/threads/base.py
Thread.make_simple
def make_simple(self): """ Return a cylinder with the thread's average radius & length. :math:`radius = (inner_radius + outer_radius) / 2` """ (inner_radius, outer_radius) = self.get_radii() radius = (inner_radius + outer_radius) / 2 return cadquery.Workplane('XY...
python
def make_simple(self): """ Return a cylinder with the thread's average radius & length. :math:`radius = (inner_radius + outer_radius) / 2` """ (inner_radius, outer_radius) = self.get_radii() radius = (inner_radius + outer_radius) / 2 return cadquery.Workplane('XY...
[ "def", "make_simple", "(", "self", ")", ":", "(", "inner_radius", ",", "outer_radius", ")", "=", "self", ".", "get_radii", "(", ")", "radius", "=", "(", "inner_radius", "+", "outer_radius", ")", "/", "2", "return", "cadquery", ".", "Workplane", "(", "'XY...
Return a cylinder with the thread's average radius & length. :math:`radius = (inner_radius + outer_radius) / 2`
[ "Return", "a", "cylinder", "with", "the", "thread", "s", "average", "radius", "&", "length", "." ]
train
https://github.com/cqparts/cqparts/blob/018e87e14c2c4d1d40b4bfe6a7e22bcf9baf0a53/src/cqparts_fasteners/solidtypes/threads/base.py#L362-L371