repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.write_byte
def write_byte(self, byte): """Write one byte.""" self.payload[self.pos] = byte self.pos = self.pos + 1
python
def write_byte(self, byte): """Write one byte.""" self.payload[self.pos] = byte self.pos = self.pos + 1
[ "def", "write_byte", "(", "self", ",", "byte", ")", ":", "self", ".", "payload", "[", "self", ".", "pos", "]", "=", "byte", "self", ".", "pos", "=", "self", ".", "pos", "+", "1" ]
Write one byte.
[ "Write", "one", "byte", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L171-L174
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.write_bytes
def write_bytes(self, data, n): """Write n number of bytes to this packet.""" for pos in xrange(0, n): self.payload[self.pos + pos] = data[pos] self.pos += n
python
def write_bytes(self, data, n): """Write n number of bytes to this packet.""" for pos in xrange(0, n): self.payload[self.pos + pos] = data[pos] self.pos += n
[ "def", "write_bytes", "(", "self", ",", "data", ",", "n", ")", ":", "for", "pos", "in", "xrange", "(", "0", ",", "n", ")", ":", "self", ".", "payload", "[", "self", ".", "pos", "+", "pos", "]", "=", "data", "[", "pos", "]", "self", ".", "pos"...
Write n number of bytes to this packet.
[ "Write", "n", "number", "of", "bytes", "to", "this", "packet", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L176-L181
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.read_byte
def read_byte(self): """Read a byte.""" if self.pos + 1 > self.remaining_length: return NC.ERR_PROTOCOL, None byte = self.payload[self.pos] self.pos += 1 return NC.ERR_SUCCESS, byte
python
def read_byte(self): """Read a byte.""" if self.pos + 1 > self.remaining_length: return NC.ERR_PROTOCOL, None byte = self.payload[self.pos] self.pos += 1 return NC.ERR_SUCCESS, byte
[ "def", "read_byte", "(", "self", ")", ":", "if", "self", ".", "pos", "+", "1", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", ",", "None", "byte", "=", "self", ".", "payload", "[", "self", ".", "pos", "]", "self", "...
Read a byte.
[ "Read", "a", "byte", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L183-L191
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.read_uint16
def read_uint16(self): """Read 2 bytes.""" if self.pos + 2 > self.remaining_length: return NC.ERR_PROTOCOL msb = self.payload[self.pos] self.pos += 1 lsb = self.payload[self.pos] self.pos += 1 word = (msb << 8) + lsb return NC...
python
def read_uint16(self): """Read 2 bytes.""" if self.pos + 2 > self.remaining_length: return NC.ERR_PROTOCOL msb = self.payload[self.pos] self.pos += 1 lsb = self.payload[self.pos] self.pos += 1 word = (msb << 8) + lsb return NC...
[ "def", "read_uint16", "(", "self", ")", ":", "if", "self", ".", "pos", "+", "2", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", "msb", "=", "self", ".", "payload", "[", "self", ".", "pos", "]", "self", ".", "pos", "...
Read 2 bytes.
[ "Read", "2", "bytes", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L193-L204
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.read_bytes
def read_bytes(self, count): """Read count number of bytes.""" if self.pos + count > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(count) for x in xrange(0, count): ba[x] = self.payload[self.pos] self.pos += 1 ...
python
def read_bytes(self, count): """Read count number of bytes.""" if self.pos + count > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(count) for x in xrange(0, count): ba[x] = self.payload[self.pos] self.pos += 1 ...
[ "def", "read_bytes", "(", "self", ",", "count", ")", ":", "if", "self", ".", "pos", "+", "count", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", ",", "None", "ba", "=", "bytearray", "(", "count", ")", "for", "x", "in"...
Read count number of bytes.
[ "Read", "count", "number", "of", "bytes", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L206-L216
iwanbk/nyamuk
nyamuk/mqtt_pkt.py
MqttPkt.read_string
def read_string(self): """Read string.""" rc, length = self.read_uint16() if rc != NC.ERR_SUCCESS: return rc, None if self.pos + length > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(length) if ba is...
python
def read_string(self): """Read string.""" rc, length = self.read_uint16() if rc != NC.ERR_SUCCESS: return rc, None if self.pos + length > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(length) if ba is...
[ "def", "read_string", "(", "self", ")", ":", "rc", ",", "length", "=", "self", ".", "read_uint16", "(", ")", "if", "rc", "!=", "NC", ".", "ERR_SUCCESS", ":", "return", "rc", ",", "None", "if", "self", ".", "pos", "+", "length", ">", "self", ".", ...
Read string.
[ "Read", "string", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L218-L236
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.pop_event
def pop_event(self): """Pop an event from event_list.""" if len(self.event_list) > 0: evt = self.event_list.pop(0) return evt return None
python
def pop_event(self): """Pop an event from event_list.""" if len(self.event_list) > 0: evt = self.event_list.pop(0) return evt return None
[ "def", "pop_event", "(", "self", ")", ":", "if", "len", "(", "self", ".", "event_list", ")", ">", "0", ":", "evt", "=", "self", ".", "event_list", ".", "pop", "(", "0", ")", "return", "evt", "return", "None" ]
Pop an event from event_list.
[ "Pop", "an", "event", "from", "event_list", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L66-L71
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.mid_generate
def mid_generate(self): """Generate mid. TODO : check.""" self.last_mid += 1 if self.last_mid == 0: self.last_mid += 1 return self.last_mid
python
def mid_generate(self): """Generate mid. TODO : check.""" self.last_mid += 1 if self.last_mid == 0: self.last_mid += 1 return self.last_mid
[ "def", "mid_generate", "(", "self", ")", ":", "self", ".", "last_mid", "+=", "1", "if", "self", ".", "last_mid", "==", "0", ":", "self", ".", "last_mid", "+=", "1", "return", "self", ".", "last_mid" ]
Generate mid. TODO : check.
[ "Generate", "mid", ".", "TODO", ":", "check", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L77-L82
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.packet_queue
def packet_queue(self, pkt): """Enqueue packet to out_packet queue.""" pkt.pos = 0 pkt.to_process = pkt.packet_length self.out_packet.append(pkt) return NC.ERR_SUCCESS
python
def packet_queue(self, pkt): """Enqueue packet to out_packet queue.""" pkt.pos = 0 pkt.to_process = pkt.packet_length self.out_packet.append(pkt) return NC.ERR_SUCCESS
[ "def", "packet_queue", "(", "self", ",", "pkt", ")", ":", "pkt", ".", "pos", "=", "0", "pkt", ".", "to_process", "=", "pkt", ".", "packet_length", "self", ".", "out_packet", ".", "append", "(", "pkt", ")", "return", "NC", ".", "ERR_SUCCESS" ]
Enqueue packet to out_packet queue.
[ "Enqueue", "packet", "to", "out_packet", "queue", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L87-L94
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.packet_write
def packet_write(self): """Write packet to network.""" bytes_written = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN, bytes_written while len(self.out_packet) > 0: pkt = self.out_packet[0] write_length, status = nyamuk_ne...
python
def packet_write(self): """Write packet to network.""" bytes_written = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN, bytes_written while len(self.out_packet) > 0: pkt = self.out_packet[0] write_length, status = nyamuk_ne...
[ "def", "packet_write", "(", "self", ")", ":", "bytes_written", "=", "0", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", ",", "bytes_written", "while", "len", "(", "self", ".", "out_packet", ")", ">"...
Write packet to network.
[ "Write", "packet", "to", "network", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L96-L137
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.packet_read
def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) if errnum == 0 ...
python
def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) if errnum == 0 ...
[ "def", "packet_read", "(", "self", ")", ":", "bytes_received", "=", "0", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "if", "self", ".", "in_packet", ".", "command", "==", "0", ":", "ba_data", "...
Read packet from network.
[ "Read", "packet", "from", "network", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L139-L230
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.socket_close
def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
python
def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
[ "def", "socket_close", "(", "self", ")", ":", "if", "self", ".", "sock", "!=", "NC", ".", "INVALID_SOCKET", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "NC", ".", "INVALID_SOCKET" ]
Close our socket.
[ "Close", "our", "socket", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L232-L236
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.build_publish_pkt
def build_publish_pkt(self, mid, topic, payload, qos, retain, dup): """Build PUBLISH packet.""" pkt = MqttPkt() payloadlen = len(payload) packetlen = 2 + len(topic) + payloadlen if qos > 0: packetlen += 2 pkt.mid = mid pkt.command = N...
python
def build_publish_pkt(self, mid, topic, payload, qos, retain, dup): """Build PUBLISH packet.""" pkt = MqttPkt() payloadlen = len(payload) packetlen = 2 + len(topic) + payloadlen if qos > 0: packetlen += 2 pkt.mid = mid pkt.command = N...
[ "def", "build_publish_pkt", "(", "self", ",", "mid", ",", "topic", ",", "payload", ",", "qos", ",", "retain", ",", "dup", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "payloadlen", "=", "len", "(", "payload", ")", "packetlen", "=", "2", "+", "len", "...
Build PUBLISH packet.
[ "Build", "PUBLISH", "packet", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L251-L278
iwanbk/nyamuk
nyamuk/base_nyamuk.py
BaseNyamuk.send_simple_command
def send_simple_command(self, cmd): """Send simple mqtt commands.""" pkt = MqttPkt() pkt.command = cmd pkt.remaining_length = 0 ret = pkt.alloc() if ret != NC.ERR_SUCCESS: return ret return self.packet_queue(pkt)
python
def send_simple_command(self, cmd): """Send simple mqtt commands.""" pkt = MqttPkt() pkt.command = cmd pkt.remaining_length = 0 ret = pkt.alloc() if ret != NC.ERR_SUCCESS: return ret return self.packet_queue(pkt)
[ "def", "send_simple_command", "(", "self", ",", "cmd", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "pkt", ".", "command", "=", "cmd", "pkt", ".", "remaining_length", "=", "0", "ret", "=", "pkt", ".", "alloc", "(", ")", "if", "ret", "!=", "NC", ".", ...
Send simple mqtt commands.
[ "Send", "simple", "mqtt", "commands", "." ]
train
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L280-L291
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger.real_ip
def real_ip(self): """ The actual public IP of this host. """ if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
python
def real_ip(self): """ The actual public IP of this host. """ if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
[ "def", "real_ip", "(", "self", ")", ":", "if", "self", ".", "_real_ip", "is", "None", ":", "response", "=", "get", "(", "ICANHAZIP", ")", "self", ".", "_real_ip", "=", "self", ".", "_get_response_text", "(", "response", ")", "return", "self", ".", "_re...
The actual public IP of this host.
[ "The", "actual", "public", "IP", "of", "this", "host", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L72-L80
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger.get_current_ip
def get_current_ip(self): """ Get the current IP Tor is using. :returns str :raises TorIpError """ response = get(ICANHAZIP, proxies={"http": self.local_http_proxy}) if response.ok: return self._get_response_text(response) raise TorIpError("...
python
def get_current_ip(self): """ Get the current IP Tor is using. :returns str :raises TorIpError """ response = get(ICANHAZIP, proxies={"http": self.local_http_proxy}) if response.ok: return self._get_response_text(response) raise TorIpError("...
[ "def", "get_current_ip", "(", "self", ")", ":", "response", "=", "get", "(", "ICANHAZIP", ",", "proxies", "=", "{", "\"http\"", ":", "self", ".", "local_http_proxy", "}", ")", "if", "response", ".", "ok", ":", "return", "self", ".", "_get_response_text", ...
Get the current IP Tor is using. :returns str :raises TorIpError
[ "Get", "the", "current", "IP", "Tor", "is", "using", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L82-L94
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger.get_new_ip
def get_new_ip(self): """ Try to obtain new a usable TOR IP. :returns bool :raises TorIpError """ attempts = 0 while True: if attempts == self.new_ip_max_attempts: raise TorIpError("Failed to obtain a new usable Tor IP") ...
python
def get_new_ip(self): """ Try to obtain new a usable TOR IP. :returns bool :raises TorIpError """ attempts = 0 while True: if attempts == self.new_ip_max_attempts: raise TorIpError("Failed to obtain a new usable Tor IP") ...
[ "def", "get_new_ip", "(", "self", ")", ":", "attempts", "=", "0", "while", "True", ":", "if", "attempts", "==", "self", ".", "new_ip_max_attempts", ":", "raise", "TorIpError", "(", "\"Failed to obtain a new usable Tor IP\"", ")", "attempts", "+=", "1", "try", ...
Try to obtain new a usable TOR IP. :returns bool :raises TorIpError
[ "Try", "to", "obtain", "new", "a", "usable", "TOR", "IP", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L96-L124
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger._ip_is_usable
def _ip_is_usable(self, current_ip): """ Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool """ # Consider IP addresses only. try: ipaddress.ip_address(current_ip) except ...
python
def _ip_is_usable(self, current_ip): """ Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool """ # Consider IP addresses only. try: ipaddress.ip_address(current_ip) except ...
[ "def", "_ip_is_usable", "(", "self", ",", "current_ip", ")", ":", "# Consider IP addresses only.", "try", ":", "ipaddress", ".", "ip_address", "(", "current_ip", ")", "except", "ValueError", ":", "return", "False", "# Never use real IP.", "if", "current_ip", "==", ...
Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool
[ "Check", "if", "the", "current", "Tor", "s", "IP", "is", "usable", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L140-L163
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger._manage_used_ips
def _manage_used_ips(self, current_ip): """ Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str """ # Register current IP. self.used_ips.append(current_ip) # Release the oldest registred IP. i...
python
def _manage_used_ips(self, current_ip): """ Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str """ # Register current IP. self.used_ips.append(current_ip) # Release the oldest registred IP. i...
[ "def", "_manage_used_ips", "(", "self", ",", "current_ip", ")", ":", "# Register current IP.", "self", ".", "used_ips", ".", "append", "(", "current_ip", ")", "# Release the oldest registred IP.", "if", "self", ".", "reuse_threshold", ":", "if", "len", "(", "self"...
Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str
[ "Handle", "registering", "and", "releasing", "used", "Tor", "IPs", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L165-L178
DusanMadar/TorIpChanger
toripchanger/changer.py
TorIpChanger._obtain_new_ip
def _obtain_new_ip(self): """ Change Tor's IP. """ with Controller.from_port( address=self.tor_address, port=self.tor_port ) as controller: controller.authenticate(password=self.tor_password) controller.signal(Signal.NEWNYM) # Wait til...
python
def _obtain_new_ip(self): """ Change Tor's IP. """ with Controller.from_port( address=self.tor_address, port=self.tor_port ) as controller: controller.authenticate(password=self.tor_password) controller.signal(Signal.NEWNYM) # Wait til...
[ "def", "_obtain_new_ip", "(", "self", ")", ":", "with", "Controller", ".", "from_port", "(", "address", "=", "self", ".", "tor_address", ",", "port", "=", "self", ".", "tor_port", ")", "as", "controller", ":", "controller", ".", "authenticate", "(", "passw...
Change Tor's IP.
[ "Change", "Tor", "s", "IP", "." ]
train
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L180-L191
devassistant/devassistant
devassistant/excepthook.py
is_local_subsection
def is_local_subsection(command_dict): """Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.""" for local_com in ['if ', 'for ', 'else ']: if list(command_dict.keys())[0].startswith(local_com): ...
python
def is_local_subsection(command_dict): """Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.""" for local_com in ['if ', 'for ', 'else ']: if list(command_dict.keys())[0].startswith(local_com): ...
[ "def", "is_local_subsection", "(", "command_dict", ")", ":", "for", "local_com", "in", "[", "'if '", ",", "'for '", ",", "'else '", "]", ":", "if", "list", "(", "command_dict", ".", "keys", "(", ")", ")", "[", "0", "]", ".", "startswith", "(", "local_c...
Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.
[ "Returns", "True", "if", "command", "dict", "is", "local", "subsection", "meaning", "that", "it", "is", "if", "else", "or", "for", "(", "not", "a", "real", "call", "but", "calls", "run_section", "recursively", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/excepthook.py#L24-L31
devassistant/devassistant
devassistant/dapi/dapicli.py
_process_req_txt
def _process_req_txt(req): '''Returns a processed request or raises an exception''' if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) return req.text
python
def _process_req_txt(req): '''Returns a processed request or raises an exception''' if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) return req.text
[ "def", "_process_req_txt", "(", "req", ")", ":", "if", "req", ".", "status_code", "==", "404", ":", "return", "''", "if", "req", ".", "status_code", "!=", "200", ":", "raise", "DapiCommError", "(", "'Response of the server was {code}'", ".", "format", "(", "...
Returns a processed request or raises an exception
[ "Returns", "a", "processed", "request", "or", "raises", "an", "exception" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L49-L55
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_from_dapi_or_mirror
def _get_from_dapi_or_mirror(link): '''Tries to get the link form DAPI or the mirror''' exception = False try: req = requests.get(_api_url() + link, timeout=5) except requests.exceptions.RequestException: exception = True attempts = 1 while exception or str(req.status_code).star...
python
def _get_from_dapi_or_mirror(link): '''Tries to get the link form DAPI or the mirror''' exception = False try: req = requests.get(_api_url() + link, timeout=5) except requests.exceptions.RequestException: exception = True attempts = 1 while exception or str(req.status_code).star...
[ "def", "_get_from_dapi_or_mirror", "(", "link", ")", ":", "exception", "=", "False", "try", ":", "req", "=", "requests", ".", "get", "(", "_api_url", "(", ")", "+", "link", ",", "timeout", "=", "5", ")", "except", "requests", ".", "exceptions", ".", "R...
Tries to get the link form DAPI or the mirror
[ "Tries", "to", "get", "the", "link", "form", "DAPI", "or", "the", "mirror" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L63-L83
devassistant/devassistant
devassistant/dapi/dapicli.py
_remove_api_url_from_link
def _remove_api_url_from_link(link): '''Remove the API URL from the link if it is there''' if link.startswith(_api_url()): link = link[len(_api_url()):] if link.startswith(_api_url(mirror=True)): link = link[len(_api_url(mirror=True)):] return link
python
def _remove_api_url_from_link(link): '''Remove the API URL from the link if it is there''' if link.startswith(_api_url()): link = link[len(_api_url()):] if link.startswith(_api_url(mirror=True)): link = link[len(_api_url(mirror=True)):] return link
[ "def", "_remove_api_url_from_link", "(", "link", ")", ":", "if", "link", ".", "startswith", "(", "_api_url", "(", ")", ")", ":", "link", "=", "link", "[", "len", "(", "_api_url", "(", ")", ")", ":", "]", "if", "link", ".", "startswith", "(", "_api_ur...
Remove the API URL from the link if it is there
[ "Remove", "the", "API", "URL", "from", "the", "link", "if", "it", "is", "there" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L86-L92
devassistant/devassistant
devassistant/dapi/dapicli.py
data
def data(link): '''Returns a dictionary from requested link''' link = _remove_api_url_from_link(link) req = _get_from_dapi_or_mirror(link) return _process_req(req)
python
def data(link): '''Returns a dictionary from requested link''' link = _remove_api_url_from_link(link) req = _get_from_dapi_or_mirror(link) return _process_req(req)
[ "def", "data", "(", "link", ")", ":", "link", "=", "_remove_api_url_from_link", "(", "link", ")", "req", "=", "_get_from_dapi_or_mirror", "(", "link", ")", "return", "_process_req", "(", "req", ")" ]
Returns a dictionary from requested link
[ "Returns", "a", "dictionary", "from", "requested", "link" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L95-L99
devassistant/devassistant
devassistant/dapi/dapicli.py
_unpaginated
def _unpaginated(what): '''Returns a dictionary with all <what>, unpaginated''' page = data(what) results = page['results'] count = page['count'] while page['next']: page = data(page['next']) results += page['results'] count += page['count'] return {'results': results, 'c...
python
def _unpaginated(what): '''Returns a dictionary with all <what>, unpaginated''' page = data(what) results = page['results'] count = page['count'] while page['next']: page = data(page['next']) results += page['results'] count += page['count'] return {'results': results, 'c...
[ "def", "_unpaginated", "(", "what", ")", ":", "page", "=", "data", "(", "what", ")", "results", "=", "page", "[", "'results'", "]", "count", "=", "page", "[", "'count'", "]", "while", "page", "[", "'next'", "]", ":", "page", "=", "data", "(", "page...
Returns a dictionary with all <what>, unpaginated
[ "Returns", "a", "dictionary", "with", "all", "<what", ">", "unpaginated" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L102-L111
devassistant/devassistant
devassistant/dapi/dapicli.py
search
def search(q, **kwargs): '''Returns a dictionary with the search results''' data = {'q': q} for key, value in kwargs.items(): if value: if type(value) == bool: data[key] = 'on' else: data[key] = value return _unpaginated('search/?' + urlenc...
python
def search(q, **kwargs): '''Returns a dictionary with the search results''' data = {'q': q} for key, value in kwargs.items(): if value: if type(value) == bool: data[key] = 'on' else: data[key] = value return _unpaginated('search/?' + urlenc...
[ "def", "search", "(", "q", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'q'", ":", "q", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "value", ":", "if", "type", "(", "value", ")", "==", "bool", ...
Returns a dictionary with the search results
[ "Returns", "a", "dictionary", "with", "the", "search", "results" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L146-L155
devassistant/devassistant
devassistant/dapi/dapicli.py
format_users
def format_users(): '''Formats a list of users available on Dapi''' lines = [] u = users() count = u['count'] if not count: raise DapiCommError('Could not find any users on DAPI.') for user in u['results']: line = user['username'] if user['full_name']: line +=...
python
def format_users(): '''Formats a list of users available on Dapi''' lines = [] u = users() count = u['count'] if not count: raise DapiCommError('Could not find any users on DAPI.') for user in u['results']: line = user['username'] if user['full_name']: line +=...
[ "def", "format_users", "(", ")", ":", "lines", "=", "[", "]", "u", "=", "users", "(", ")", "count", "=", "u", "[", "'count'", "]", "if", "not", "count", ":", "raise", "DapiCommError", "(", "'Could not find any users on DAPI.'", ")", "for", "user", "in", ...
Formats a list of users available on Dapi
[ "Formats", "a", "list", "of", "users", "available", "on", "Dapi" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L167-L179
devassistant/devassistant
devassistant/dapi/dapicli.py
format_daps
def format_daps(simple=False, skip_installed=False): '''Formats a list of metadaps available on Dapi''' lines= [] m = metadaps() if not m['count']: logger.info('Could not find any daps') return for mdap in sorted(m['results'], key=lambda mdap: mdap['package_name']): if skip_i...
python
def format_daps(simple=False, skip_installed=False): '''Formats a list of metadaps available on Dapi''' lines= [] m = metadaps() if not m['count']: logger.info('Could not find any daps') return for mdap in sorted(m['results'], key=lambda mdap: mdap['package_name']): if skip_i...
[ "def", "format_daps", "(", "simple", "=", "False", ",", "skip_installed", "=", "False", ")", ":", "lines", "=", "[", "]", "m", "=", "metadaps", "(", ")", "if", "not", "m", "[", "'count'", "]", ":", "logger", ".", "info", "(", "'Could not find any daps'...
Formats a list of metadaps available on Dapi
[ "Formats", "a", "list", "of", "metadaps", "available", "on", "Dapi" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L182-L197
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_metadap_dap
def _get_metadap_dap(name, version=''): '''Return data for dap of given or latest version.''' m = metadap(name) if not m: raise DapiCommError('DAP {dap} not found.'.format(dap=name)) if not version: d = m['latest_stable'] or m['latest'] if d: d = data(d) else: ...
python
def _get_metadap_dap(name, version=''): '''Return data for dap of given or latest version.''' m = metadap(name) if not m: raise DapiCommError('DAP {dap} not found.'.format(dap=name)) if not version: d = m['latest_stable'] or m['latest'] if d: d = data(d) else: ...
[ "def", "_get_metadap_dap", "(", "name", ",", "version", "=", "''", ")", ":", "m", "=", "metadap", "(", "name", ")", "if", "not", "m", ":", "raise", "DapiCommError", "(", "'DAP {dap} not found.'", ".", "format", "(", "dap", "=", "name", ")", ")", "if", ...
Return data for dap of given or latest version.
[ "Return", "data", "for", "dap", "of", "given", "or", "latest", "version", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L200-L214
devassistant/devassistant
devassistant/dapi/dapicli.py
format_dap_from_dapi
def format_dap_from_dapi(name, version='', full=False): '''Formats information about given DAP from DAPI in a human readable form to list of lines''' lines = [] m, d = _get_metadap_dap(name, version) if d: # Determining label width labels = BASIC_LABELS + ['average_rank'] # average_rank...
python
def format_dap_from_dapi(name, version='', full=False): '''Formats information about given DAP from DAPI in a human readable form to list of lines''' lines = [] m, d = _get_metadap_dap(name, version) if d: # Determining label width labels = BASIC_LABELS + ['average_rank'] # average_rank...
[ "def", "format_dap_from_dapi", "(", "name", ",", "version", "=", "''", ",", "full", "=", "False", ")", ":", "lines", "=", "[", "]", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", ")", "if", "d", ":", "# Determining label width", "...
Formats information about given DAP from DAPI in a human readable form to list of lines
[ "Formats", "information", "about", "given", "DAP", "from", "DAPI", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L217-L252
devassistant/devassistant
devassistant/dapi/dapicli.py
format_local_dap
def format_local_dap(dap, full=False, **kwargs): '''Formaqts information about the given local DAP in a human readable form to list of lines''' lines = [] # Determining label width label_width = dapi.DapFormatter.calculate_offset(BASIC_LABELS) # Metadata lines.append(dapi.DapFormatter.format_m...
python
def format_local_dap(dap, full=False, **kwargs): '''Formaqts information about the given local DAP in a human readable form to list of lines''' lines = [] # Determining label width label_width = dapi.DapFormatter.calculate_offset(BASIC_LABELS) # Metadata lines.append(dapi.DapFormatter.format_m...
[ "def", "format_local_dap", "(", "dap", ",", "full", "=", "False", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "[", "]", "# Determining label width", "label_width", "=", "dapi", ".", "DapFormatter", ".", "calculate_offset", "(", "BASIC_LABELS", ")", "# M...
Formaqts information about the given local DAP in a human readable form to list of lines
[ "Formaqts", "information", "about", "the", "given", "local", "DAP", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L255-L281
devassistant/devassistant
devassistant/dapi/dapicli.py
format_installed_dap
def format_installed_dap(name, full=False): '''Formats information about an installed DAP in a human readable form to list of lines''' dap_data = get_installed_daps_detailed().get(name) if not dap_data: raise DapiLocalError('DAP "{dap}" is not installed, can not query for info.'.format(dap=name)) ...
python
def format_installed_dap(name, full=False): '''Formats information about an installed DAP in a human readable form to list of lines''' dap_data = get_installed_daps_detailed().get(name) if not dap_data: raise DapiLocalError('DAP "{dap}" is not installed, can not query for info.'.format(dap=name)) ...
[ "def", "format_installed_dap", "(", "name", ",", "full", "=", "False", ")", ":", "dap_data", "=", "get_installed_daps_detailed", "(", ")", ".", "get", "(", "name", ")", "if", "not", "dap_data", ":", "raise", "DapiLocalError", "(", "'DAP \"{dap}\" is not installe...
Formats information about an installed DAP in a human readable form to list of lines
[ "Formats", "information", "about", "an", "installed", "DAP", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L284-L299
devassistant/devassistant
devassistant/dapi/dapicli.py
format_installed_dap_list
def format_installed_dap_list(simple=False): '''Formats all installed DAPs in a human readable form to list of lines''' lines = [] if simple: for pkg in sorted(get_installed_daps()): lines.append(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): ...
python
def format_installed_dap_list(simple=False): '''Formats all installed DAPs in a human readable form to list of lines''' lines = [] if simple: for pkg in sorted(get_installed_daps()): lines.append(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): ...
[ "def", "format_installed_dap_list", "(", "simple", "=", "False", ")", ":", "lines", "=", "[", "]", "if", "simple", ":", "for", "pkg", "in", "sorted", "(", "get_installed_daps", "(", ")", ")", ":", "lines", ".", "append", "(", "pkg", ")", "else", ":", ...
Formats all installed DAPs in a human readable form to list of lines
[ "Formats", "all", "installed", "DAPs", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L302-L319
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_assistants_snippets
def _get_assistants_snippets(path, name): '''Get Assistants and Snippets for a given DAP name on a given path''' result = [] subdirs = {'assistants': 2, 'snippets': 1} # Values used for stripping leading path tokens for loc in subdirs: for root, dirs, files in os.walk(os.path.join(path, loc)): ...
python
def _get_assistants_snippets(path, name): '''Get Assistants and Snippets for a given DAP name on a given path''' result = [] subdirs = {'assistants': 2, 'snippets': 1} # Values used for stripping leading path tokens for loc in subdirs: for root, dirs, files in os.walk(os.path.join(path, loc)): ...
[ "def", "_get_assistants_snippets", "(", "path", ",", "name", ")", ":", "result", "=", "[", "]", "subdirs", "=", "{", "'assistants'", ":", "2", ",", "'snippets'", ":", "1", "}", "# Values used for stripping leading path tokens", "for", "loc", "in", "subdirs", "...
Get Assistants and Snippets for a given DAP name on a given path
[ "Get", "Assistants", "and", "Snippets", "for", "a", "given", "DAP", "name", "on", "a", "given", "path" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L322-L334
devassistant/devassistant
devassistant/dapi/dapicli.py
format_search
def format_search(q, **kwargs): '''Formats the results of a search''' m = search(q, **kwargs) count = m['count'] if not count: raise DapiCommError('Could not find any DAP packages for your query.') return for mdap in m['results']: mdap = mdap['content_object'] return ...
python
def format_search(q, **kwargs): '''Formats the results of a search''' m = search(q, **kwargs) count = m['count'] if not count: raise DapiCommError('Could not find any DAP packages for your query.') return for mdap in m['results']: mdap = mdap['content_object'] return ...
[ "def", "format_search", "(", "q", ",", "*", "*", "kwargs", ")", ":", "m", "=", "search", "(", "q", ",", "*", "*", "kwargs", ")", "count", "=", "m", "[", "'count'", "]", "if", "not", "count", ":", "raise", "DapiCommError", "(", "'Could not find any DA...
Formats the results of a search
[ "Formats", "the", "results", "of", "a", "search" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L337-L346
devassistant/devassistant
devassistant/dapi/dapicli.py
get_installed_daps
def get_installed_daps(location=None, skip_distro=False): '''Returns a set of all installed daps Either in the given location or in all of them''' if location: locations = [location] else: locations = _data_dirs() s = set() for loc in locations: if skip_distro and loc == ...
python
def get_installed_daps(location=None, skip_distro=False): '''Returns a set of all installed daps Either in the given location or in all of them''' if location: locations = [location] else: locations = _data_dirs() s = set() for loc in locations: if skip_distro and loc == ...
[ "def", "get_installed_daps", "(", "location", "=", "None", ",", "skip_distro", "=", "False", ")", ":", "if", "location", ":", "locations", "=", "[", "location", "]", "else", ":", "locations", "=", "_data_dirs", "(", ")", "s", "=", "set", "(", ")", "for...
Returns a set of all installed daps Either in the given location or in all of them
[ "Returns", "a", "set", "of", "all", "installed", "daps", "Either", "in", "the", "given", "location", "or", "in", "all", "of", "them" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L349-L363
devassistant/devassistant
devassistant/dapi/dapicli.py
get_installed_daps_detailed
def get_installed_daps_detailed(): '''Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred''' daps = {} for loc in _data_dirs(): s = get_installed_daps(loc) for dap in s: if dap...
python
def get_installed_daps_detailed(): '''Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred''' daps = {} for loc in _data_dirs(): s = get_installed_daps(loc) for dap in s: if dap...
[ "def", "get_installed_daps_detailed", "(", ")", ":", "daps", "=", "{", "}", "for", "loc", "in", "_data_dirs", "(", ")", ":", "s", "=", "get_installed_daps", "(", "loc", ")", "for", "dap", "in", "s", ":", "if", "dap", "not", "in", "daps", ":", "daps",...
Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred
[ "Returns", "a", "dictionary", "with", "all", "installed", "daps", "and", "their", "versions", "and", "locations", "First", "version", "and", "location", "in", "the", "dap", "s", "list", "is", "the", "one", "that", "is", "preferred" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L366-L376
devassistant/devassistant
devassistant/dapi/dapicli.py
download_dap
def download_dap(name, version='', d='', directory=''): '''Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted ''' if not d: m, d = _get_metadap_dap(name, version) if directory: _dir = director...
python
def download_dap(name, version='', d='', directory=''): '''Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted ''' if not d: m, d = _get_metadap_dap(name, version) if directory: _dir = director...
[ "def", "download_dap", "(", "name", ",", "version", "=", "''", ",", "d", "=", "''", ",", "directory", "=", "''", ")", ":", "if", "not", "d", ":", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", ")", "if", "directory", ":", "_...
Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted
[ "Download", "a", "dap", "to", "a", "given", "or", "temporary", "directory", "Return", "a", "path", "to", "that", "file", "together", "with", "information", "if", "the", "directory", "should", "be", "later", "deleted" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L448-L472
devassistant/devassistant
devassistant/dapi/dapicli.py
install_dap_from_path
def install_dap_from_path(path, update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Installs a dap from a given path''' will_uninstall = False dap_obj = dapi.Dap(path) name = dap_obj.meta['package_name'] if name in ge...
python
def install_dap_from_path(path, update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Installs a dap from a given path''' will_uninstall = False dap_obj = dapi.Dap(path) name = dap_obj.meta['package_name'] if name in ge...
[ "def", "install_dap_from_path", "(", "path", ",", "update", "=", "False", ",", "update_allpaths", "=", "False", ",", "first", "=", "True", ",", "force", "=", "False", ",", "nodeps", "=", "False", ",", "reinstall", "=", "False", ",", "__ui__", "=", "''", ...
Installs a dap from a given path
[ "Installs", "a", "dap", "from", "a", "given", "path" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L475-L568
devassistant/devassistant
devassistant/dapi/dapicli.py
_strip_version_from_dependency
def _strip_version_from_dependency(dep): '''For given dependency string, return only the package name''' usedmark = '' for mark in '< > ='.split(): split = dep.split(mark) if len(split) > 1: usedmark = mark break if usedmark: return split[0].strip() el...
python
def _strip_version_from_dependency(dep): '''For given dependency string, return only the package name''' usedmark = '' for mark in '< > ='.split(): split = dep.split(mark) if len(split) > 1: usedmark = mark break if usedmark: return split[0].strip() el...
[ "def", "_strip_version_from_dependency", "(", "dep", ")", ":", "usedmark", "=", "''", "for", "mark", "in", "'< > ='", ".", "split", "(", ")", ":", "split", "=", "dep", ".", "split", "(", "mark", ")", "if", "len", "(", "split", ")", ">", "1", ":", "...
For given dependency string, return only the package name
[ "For", "given", "dependency", "string", "return", "only", "the", "package", "name" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L571-L582
devassistant/devassistant
devassistant/dapi/dapicli.py
get_installed_version_of
def get_installed_version_of(name, location=None): '''Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one''' if location: locations = [location] else: locations = _data_dirs() for loc in locations: ...
python
def get_installed_version_of(name, location=None): '''Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one''' if location: locations = [location] else: locations = _data_dirs() for loc in locations: ...
[ "def", "get_installed_version_of", "(", "name", ",", "location", "=", "None", ")", ":", "if", "location", ":", "locations", "=", "[", "location", "]", "else", ":", "locations", "=", "_data_dirs", "(", ")", "for", "loc", "in", "locations", ":", "if", "nam...
Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one
[ "Gets", "the", "installed", "version", "of", "the", "given", "dap", "or", "None", "if", "not", "installed", "Searches", "in", "all", "dirs", "by", "default", "otherwise", "in", "the", "given", "one" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L585-L599
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_dependencies_of
def _get_dependencies_of(name, location=None): ''' Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there ''' if not locat...
python
def _get_dependencies_of(name, location=None): ''' Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there ''' if not locat...
[ "def", "_get_dependencies_of", "(", "name", ",", "location", "=", "None", ")", ":", "if", "not", "location", ":", "detailed_dap_list", "=", "get_installed_daps_detailed", "(", ")", "if", "name", "not", "in", "detailed_dap_list", ":", "return", "_get_api_dependenci...
Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there
[ "Returns", "list", "of", "first", "level", "dependencies", "of", "the", "given", "installed", "dap", "or", "dap", "from", "Dapi", "if", "not", "installed", "If", "a", "location", "is", "specified", "this", "only", "checks", "for", "dap", "installed", "in", ...
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L610-L628
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_all_dependencies_of
def _get_all_dependencies_of(name, deps=set(), force=False): '''Returns list of dependencies of the given dap from Dapi recursively''' first_deps = _get_api_dependencies_of(name, force=force) for dep in first_deps: dep = _strip_version_from_dependency(dep) if dep in deps: continu...
python
def _get_all_dependencies_of(name, deps=set(), force=False): '''Returns list of dependencies of the given dap from Dapi recursively''' first_deps = _get_api_dependencies_of(name, force=force) for dep in first_deps: dep = _strip_version_from_dependency(dep) if dep in deps: continu...
[ "def", "_get_all_dependencies_of", "(", "name", ",", "deps", "=", "set", "(", ")", ",", "force", "=", "False", ")", ":", "first_deps", "=", "_get_api_dependencies_of", "(", "name", ",", "force", "=", "force", ")", "for", "dep", "in", "first_deps", ":", "...
Returns list of dependencies of the given dap from Dapi recursively
[ "Returns", "list", "of", "dependencies", "of", "the", "given", "dap", "from", "Dapi", "recursively" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L631-L642
devassistant/devassistant
devassistant/dapi/dapicli.py
_get_api_dependencies_of
def _get_api_dependencies_of(name, version='', force=False): '''Returns list of first level dependencies of the given dap from Dapi''' m, d = _get_metadap_dap(name, version=version) # We need the dependencies to install the dap, # if the dap is unsupported, raise an exception here if not force and n...
python
def _get_api_dependencies_of(name, version='', force=False): '''Returns list of first level dependencies of the given dap from Dapi''' m, d = _get_metadap_dap(name, version=version) # We need the dependencies to install the dap, # if the dap is unsupported, raise an exception here if not force and n...
[ "def", "_get_api_dependencies_of", "(", "name", ",", "version", "=", "''", ",", "force", "=", "False", ")", ":", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", "=", "version", ")", "# We need the dependencies to install the dap,", "# if the...
Returns list of first level dependencies of the given dap from Dapi
[ "Returns", "list", "of", "first", "level", "dependencies", "of", "the", "given", "dap", "from", "Dapi" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L645-L654
devassistant/devassistant
devassistant/dapi/dapicli.py
install_dap
def install_dap(name, version='', update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Install a dap from dapi If update is True, it will remove previously installed daps of the same name''' m, d = _get_metadap_dap(name, version) if ...
python
def install_dap(name, version='', update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Install a dap from dapi If update is True, it will remove previously installed daps of the same name''' m, d = _get_metadap_dap(name, version) if ...
[ "def", "install_dap", "(", "name", ",", "version", "=", "''", ",", "update", "=", "False", ",", "update_allpaths", "=", "False", ",", "first", "=", "True", ",", "force", "=", "False", ",", "nodeps", "=", "False", ",", "reinstall", "=", "False", ",", ...
Install a dap from dapi If update is True, it will remove previously installed daps of the same name
[ "Install", "a", "dap", "from", "dapi", "If", "update", "is", "True", "it", "will", "remove", "previously", "installed", "daps", "of", "the", "same", "name" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L657-L682
devassistant/devassistant
devassistant/dapi/dapicli.py
get_dependency_metadata
def get_dependency_metadata(): '''Returns list of strings with dependency metadata from Dapi''' link = os.path.join(_api_url(), 'meta.txt') return _process_req_txt(requests.get(link)).split('\n')
python
def get_dependency_metadata(): '''Returns list of strings with dependency metadata from Dapi''' link = os.path.join(_api_url(), 'meta.txt') return _process_req_txt(requests.get(link)).split('\n')
[ "def", "get_dependency_metadata", "(", ")", ":", "link", "=", "os", ".", "path", ".", "join", "(", "_api_url", "(", ")", ",", "'meta.txt'", ")", "return", "_process_req_txt", "(", "requests", ".", "get", "(", "link", ")", ")", ".", "split", "(", "'\\n'...
Returns list of strings with dependency metadata from Dapi
[ "Returns", "list", "of", "strings", "with", "dependency", "metadata", "from", "Dapi" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L685-L688
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_frame
def create_frame(self): """ This function creates a frame """ frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) return frame
python
def create_frame(self): """ This function creates a frame """ frame = Gtk.Frame() frame.set_shadow_type(Gtk.ShadowType.IN) return frame
[ "def", "create_frame", "(", "self", ")", ":", "frame", "=", "Gtk", ".", "Frame", "(", ")", "frame", ".", "set_shadow_type", "(", "Gtk", ".", "ShadowType", ".", "IN", ")", "return", "frame" ]
This function creates a frame
[ "This", "function", "creates", "a", "frame" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L22-L28
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_box
def create_box(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0): """ Function creates box. Based on orientation it can be either HORIZONTAL or VERTICAL """ h_box = Gtk.Box(orientation=orientation, spacing=spacing) h_box.set_homogeneous(False) retur...
python
def create_box(self, orientation=Gtk.Orientation.HORIZONTAL, spacing=0): """ Function creates box. Based on orientation it can be either HORIZONTAL or VERTICAL """ h_box = Gtk.Box(orientation=orientation, spacing=spacing) h_box.set_homogeneous(False) retur...
[ "def", "create_box", "(", "self", ",", "orientation", "=", "Gtk", ".", "Orientation", ".", "HORIZONTAL", ",", "spacing", "=", "0", ")", ":", "h_box", "=", "Gtk", ".", "Box", "(", "orientation", "=", "orientation", ",", "spacing", "=", "spacing", ")", "...
Function creates box. Based on orientation it can be either HORIZONTAL or VERTICAL
[ "Function", "creates", "box", ".", "Based", "on", "orientation", "it", "can", "be", "either", "HORIZONTAL", "or", "VERTICAL" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L30-L37
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.button_with_label
def button_with_label(self, description, assistants=None): """ Function creates a button with lave. If assistant is specified then text is aligned """ btn = self.create_button() label = self.create_label(description) if assistants is not None: ...
python
def button_with_label(self, description, assistants=None): """ Function creates a button with lave. If assistant is specified then text is aligned """ btn = self.create_button() label = self.create_label(description) if assistants is not None: ...
[ "def", "button_with_label", "(", "self", ",", "description", ",", "assistants", "=", "None", ")", ":", "btn", "=", "self", ".", "create_button", "(", ")", "label", "=", "self", ".", "create_label", "(", "description", ")", "if", "assistants", "is", "not", ...
Function creates a button with lave. If assistant is specified then text is aligned
[ "Function", "creates", "a", "button", "with", "lave", ".", "If", "assistant", "is", "specified", "then", "text", "is", "aligned" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L39-L57
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_image
def create_image(self, image_name=None, scale_ratio=1, window=None): """ The function creates a image from name defined in image_name """ size = 48 * scale_ratio pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(image_name, -1, size, True) image = Gtk.Image() ...
python
def create_image(self, image_name=None, scale_ratio=1, window=None): """ The function creates a image from name defined in image_name """ size = 48 * scale_ratio pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(image_name, -1, size, True) image = Gtk.Image() ...
[ "def", "create_image", "(", "self", ",", "image_name", "=", "None", ",", "scale_ratio", "=", "1", ",", "window", "=", "None", ")", ":", "size", "=", "48", "*", "scale_ratio", "pixbuf", "=", "GdkPixbuf", ".", "Pixbuf", ".", "new_from_file_at_scale", "(", ...
The function creates a image from name defined in image_name
[ "The", "function", "creates", "a", "image", "from", "name", "defined", "in", "image_name" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L59-L76
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.button_with_image
def button_with_image(self, description, image=None, sensitive=True): """ The function creates a button with image """ btn = self.create_button() btn.set_sensitive(sensitive) h_box = self.create_box() try: img = self.create_image(image_name=image, ...
python
def button_with_image(self, description, image=None, sensitive=True): """ The function creates a button with image """ btn = self.create_button() btn.set_sensitive(sensitive) h_box = self.create_box() try: img = self.create_image(image_name=image, ...
[ "def", "button_with_image", "(", "self", ",", "description", ",", "image", "=", "None", ",", "sensitive", "=", "True", ")", ":", "btn", "=", "self", ".", "create_button", "(", ")", "btn", ".", "set_sensitive", "(", "sensitive", ")", "h_box", "=", "self",...
The function creates a button with image
[ "The", "function", "creates", "a", "button", "with", "image" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L78-L95
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.checkbutton_with_label
def checkbutton_with_label(self, description): """ The function creates a checkbutton with label """ act_btn = Gtk.CheckButton(description) align = self.create_alignment() act_btn.add(align) return align
python
def checkbutton_with_label(self, description): """ The function creates a checkbutton with label """ act_btn = Gtk.CheckButton(description) align = self.create_alignment() act_btn.add(align) return align
[ "def", "checkbutton_with_label", "(", "self", ",", "description", ")", ":", "act_btn", "=", "Gtk", ".", "CheckButton", "(", "description", ")", "align", "=", "self", ".", "create_alignment", "(", ")", "act_btn", ".", "add", "(", "align", ")", "return", "al...
The function creates a checkbutton with label
[ "The", "function", "creates", "a", "checkbutton", "with", "label" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L97-L104
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_checkbox
def create_checkbox(self, name, margin=10): """ Function creates a checkbox with his name """ chk_btn = Gtk.CheckButton(name) chk_btn.set_margin_right(margin) return chk_btn
python
def create_checkbox(self, name, margin=10): """ Function creates a checkbox with his name """ chk_btn = Gtk.CheckButton(name) chk_btn.set_margin_right(margin) return chk_btn
[ "def", "create_checkbox", "(", "self", ",", "name", ",", "margin", "=", "10", ")", ":", "chk_btn", "=", "Gtk", ".", "CheckButton", "(", "name", ")", "chk_btn", ".", "set_margin_right", "(", "margin", ")", "return", "chk_btn" ]
Function creates a checkbox with his name
[ "Function", "creates", "a", "checkbox", "with", "his", "name" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L113-L119
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_entry
def create_entry(self, text="", sensitive="False"): """ Function creates an Entry with corresponding text """ text_entry = Gtk.Entry() text_entry.set_sensitive(sensitive) text_entry.set_text(text) return text_entry
python
def create_entry(self, text="", sensitive="False"): """ Function creates an Entry with corresponding text """ text_entry = Gtk.Entry() text_entry.set_sensitive(sensitive) text_entry.set_text(text) return text_entry
[ "def", "create_entry", "(", "self", ",", "text", "=", "\"\"", ",", "sensitive", "=", "\"False\"", ")", ":", "text_entry", "=", "Gtk", ".", "Entry", "(", ")", "text_entry", ".", "set_sensitive", "(", "sensitive", ")", "text_entry", ".", "set_text", "(", "...
Function creates an Entry with corresponding text
[ "Function", "creates", "an", "Entry", "with", "corresponding", "text" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L121-L128
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_link_button
def create_link_button(self, text="None", uri="None"): """ Function creates a link button with corresponding text and URI reference """ link_btn = Gtk.LinkButton(uri, text) return link_btn
python
def create_link_button(self, text="None", uri="None"): """ Function creates a link button with corresponding text and URI reference """ link_btn = Gtk.LinkButton(uri, text) return link_btn
[ "def", "create_link_button", "(", "self", ",", "text", "=", "\"None\"", ",", "uri", "=", "\"None\"", ")", ":", "link_btn", "=", "Gtk", ".", "LinkButton", "(", "uri", ",", "text", ")", "return", "link_btn" ]
Function creates a link button with corresponding text and URI reference
[ "Function", "creates", "a", "link", "button", "with", "corresponding", "text", "and", "URI", "reference" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L130-L136
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_button
def create_button(self, style=Gtk.ReliefStyle.NORMAL): """ This is generalized method for creating Gtk.Button """ btn = Gtk.Button() btn.set_relief(style) return btn
python
def create_button(self, style=Gtk.ReliefStyle.NORMAL): """ This is generalized method for creating Gtk.Button """ btn = Gtk.Button() btn.set_relief(style) return btn
[ "def", "create_button", "(", "self", ",", "style", "=", "Gtk", ".", "ReliefStyle", ".", "NORMAL", ")", ":", "btn", "=", "Gtk", ".", "Button", "(", ")", "btn", ".", "set_relief", "(", "style", ")", "return", "btn" ]
This is generalized method for creating Gtk.Button
[ "This", "is", "generalized", "method", "for", "creating", "Gtk", ".", "Button" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L138-L144
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_image_menu_item
def create_image_menu_item(self, text, image_name): """ Function creates a menu item with an image """ menu_item = Gtk.ImageMenuItem(text) img = self.create_image(image_name) menu_item.set_image(img) return menu_item
python
def create_image_menu_item(self, text, image_name): """ Function creates a menu item with an image """ menu_item = Gtk.ImageMenuItem(text) img = self.create_image(image_name) menu_item.set_image(img) return menu_item
[ "def", "create_image_menu_item", "(", "self", ",", "text", ",", "image_name", ")", ":", "menu_item", "=", "Gtk", ".", "ImageMenuItem", "(", "text", ")", "img", "=", "self", ".", "create_image", "(", "image_name", ")", "menu_item", ".", "set_image", "(", "i...
Function creates a menu item with an image
[ "Function", "creates", "a", "menu", "item", "with", "an", "image" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L153-L160
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_label
def create_label(self, name, justify=Gtk.Justification.CENTER, wrap_mode=True, tooltip=None): """ The function is used for creating lable with HTML text """ label = Gtk.Label() name = name.replace('|', '\n') label.set_markup(name) label.set_justify(justify) ...
python
def create_label(self, name, justify=Gtk.Justification.CENTER, wrap_mode=True, tooltip=None): """ The function is used for creating lable with HTML text """ label = Gtk.Label() name = name.replace('|', '\n') label.set_markup(name) label.set_justify(justify) ...
[ "def", "create_label", "(", "self", ",", "name", ",", "justify", "=", "Gtk", ".", "Justification", ".", "CENTER", ",", "wrap_mode", "=", "True", ",", "tooltip", "=", "None", ")", ":", "label", "=", "Gtk", ".", "Label", "(", ")", "name", "=", "name", ...
The function is used for creating lable with HTML text
[ "The", "function", "is", "used", "for", "creating", "lable", "with", "HTML", "text" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L162-L174
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.add_button
def add_button(self, grid_lang, ass, row, column): """ The function is used for creating button with all features like signal on tooltip and signal on clicked The function does not have any menu. Button is add to the Gtk.Grid on specific row and column """ #print ...
python
def add_button(self, grid_lang, ass, row, column): """ The function is used for creating button with all features like signal on tooltip and signal on clicked The function does not have any menu. Button is add to the Gtk.Grid on specific row and column """ #print ...
[ "def", "add_button", "(", "self", ",", "grid_lang", ",", "ass", ",", "row", ",", "column", ")", ":", "#print \"gui_helper add_button\"", "image_name", "=", "ass", "[", "0", "]", ".", "icon_path", "label", "=", "\"<b>\"", "+", "ass", "[", "0", "]", ".", ...
The function is used for creating button with all features like signal on tooltip and signal on clicked The function does not have any menu. Button is add to the Gtk.Grid on specific row and column
[ "The", "function", "is", "used", "for", "creating", "button", "with", "all", "features", "like", "signal", "on", "tooltip", "and", "signal", "on", "clicked", "The", "function", "does", "not", "have", "any", "menu", ".", "Button", "is", "add", "to", "the", ...
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L176-L202
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.add_install_button
def add_install_button(self, grid_lang, row, column): """ Add button that opens the window for installing more assistants """ btn = self.button_with_label('<b>Install more...</b>') if row == 0 and column == 0: grid_lang.add(btn) else: grid_lang.att...
python
def add_install_button(self, grid_lang, row, column): """ Add button that opens the window for installing more assistants """ btn = self.button_with_label('<b>Install more...</b>') if row == 0 and column == 0: grid_lang.add(btn) else: grid_lang.att...
[ "def", "add_install_button", "(", "self", ",", "grid_lang", ",", "row", ",", "column", ")", ":", "btn", "=", "self", ".", "button_with_label", "(", "'<b>Install more...</b>'", ")", "if", "row", "==", "0", "and", "column", "==", "0", ":", "grid_lang", ".", ...
Add button that opens the window for installing more assistants
[ "Add", "button", "that", "opens", "the", "window", "for", "installing", "more", "assistants" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L204-L214
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.menu_item
def menu_item(self, sub_assistant, path): """ The function creates a menu item and assigns signal like select and button-press-event for manipulation with menu_item. sub_assistant and path """ if not sub_assistant[0].icon_path: menu_item = self.create_menu_ite...
python
def menu_item(self, sub_assistant, path): """ The function creates a menu item and assigns signal like select and button-press-event for manipulation with menu_item. sub_assistant and path """ if not sub_assistant[0].icon_path: menu_item = self.create_menu_ite...
[ "def", "menu_item", "(", "self", ",", "sub_assistant", ",", "path", ")", ":", "if", "not", "sub_assistant", "[", "0", "]", ".", "icon_path", ":", "menu_item", "=", "self", ".", "create_menu_item", "(", "sub_assistant", "[", "0", "]", ".", "fullname", ")"...
The function creates a menu item and assigns signal like select and button-press-event for manipulation with menu_item. sub_assistant and path
[ "The", "function", "creates", "a", "menu", "item", "and", "assigns", "signal", "like", "select", "and", "button", "-", "press", "-", "event", "for", "manipulation", "with", "menu_item", ".", "sub_assistant", "and", "path" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L224-L245
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.generate_menu
def generate_menu(self, ass, text, path=None, level=0): """ Function generates menu from based on ass parameter """ menu = self.create_menu() for index, sub in enumerate(sorted(ass[1], key=lambda y: y[0].fullname.lower())): if index != 0: text += "|" ...
python
def generate_menu(self, ass, text, path=None, level=0): """ Function generates menu from based on ass parameter """ menu = self.create_menu() for index, sub in enumerate(sorted(ass[1], key=lambda y: y[0].fullname.lower())): if index != 0: text += "|" ...
[ "def", "generate_menu", "(", "self", ",", "ass", ",", "text", ",", "path", "=", "None", ",", "level", "=", "0", ")", ":", "menu", "=", "self", ".", "create_menu", "(", ")", "for", "index", ",", "sub", "in", "enumerate", "(", "sorted", "(", "ass", ...
Function generates menu from based on ass parameter
[ "Function", "generates", "menu", "from", "based", "on", "ass", "parameter" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L247-L266
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.add_submenu
def add_submenu(self, grid_lang, ass, row, column): """ The function is used for creating button with menu and submenu. Also signal on tooltip and signal on clicked are specified Button is add to the Gtk.Grid """ text = "Available subassistants:\n" # Generate menu...
python
def add_submenu(self, grid_lang, ass, row, column): """ The function is used for creating button with menu and submenu. Also signal on tooltip and signal on clicked are specified Button is add to the Gtk.Grid """ text = "Available subassistants:\n" # Generate menu...
[ "def", "add_submenu", "(", "self", ",", "grid_lang", ",", "ass", ",", "row", ",", "column", ")", ":", "text", "=", "\"Available subassistants:\\n\"", "# Generate menus", "path", "=", "[", "]", "(", "menu", ",", "text", ")", "=", "self", ".", "generate_menu...
The function is used for creating button with menu and submenu. Also signal on tooltip and signal on clicked are specified Button is add to the Gtk.Grid
[ "The", "function", "is", "used", "for", "creating", "button", "with", "menu", "and", "submenu", ".", "Also", "signal", "on", "tooltip", "and", "signal", "on", "clicked", "are", "specified", "Button", "is", "add", "to", "the", "Gtk", ".", "Grid" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L268-L299
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_scrolled_window
def create_scrolled_window(self, layout_manager, horizontal=Gtk.PolicyType.NEVER, vertical=Gtk.PolicyType.ALWAYS): """ Function creates a scrolled window with layout manager """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(layout_manager) scrolled_window.set...
python
def create_scrolled_window(self, layout_manager, horizontal=Gtk.PolicyType.NEVER, vertical=Gtk.PolicyType.ALWAYS): """ Function creates a scrolled window with layout manager """ scrolled_window = Gtk.ScrolledWindow() scrolled_window.add(layout_manager) scrolled_window.set...
[ "def", "create_scrolled_window", "(", "self", ",", "layout_manager", ",", "horizontal", "=", "Gtk", ".", "PolicyType", ".", "NEVER", ",", "vertical", "=", "Gtk", ".", "PolicyType", ".", "ALWAYS", ")", ":", "scrolled_window", "=", "Gtk", ".", "ScrolledWindow", ...
Function creates a scrolled window with layout manager
[ "Function", "creates", "a", "scrolled", "window", "with", "layout", "manager" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L328-L335
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_gtk_grid
def create_gtk_grid(self, row_spacing=6, col_spacing=6, row_homogenous=False, col_homogenous=True): """ Function creates a Gtk Grid with spacing and homogeous tags """ grid_lang = Gtk.Grid() grid_lang.set_column_spacing(row_spacing) grid_lang.set_row_spacing(col_s...
python
def create_gtk_grid(self, row_spacing=6, col_spacing=6, row_homogenous=False, col_homogenous=True): """ Function creates a Gtk Grid with spacing and homogeous tags """ grid_lang = Gtk.Grid() grid_lang.set_column_spacing(row_spacing) grid_lang.set_row_spacing(col_s...
[ "def", "create_gtk_grid", "(", "self", ",", "row_spacing", "=", "6", ",", "col_spacing", "=", "6", ",", "row_homogenous", "=", "False", ",", "col_homogenous", "=", "True", ")", ":", "grid_lang", "=", "Gtk", ".", "Grid", "(", ")", "grid_lang", ".", "set_c...
Function creates a Gtk Grid with spacing and homogeous tags
[ "Function", "creates", "a", "Gtk", "Grid", "with", "spacing", "and", "homogeous", "tags" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L337-L348
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_notebook
def create_notebook(self, position=Gtk.PositionType.TOP): """ Function creates a notebook """ notebook = Gtk.Notebook() notebook.set_tab_pos(position) notebook.set_show_border(True) return notebook
python
def create_notebook(self, position=Gtk.PositionType.TOP): """ Function creates a notebook """ notebook = Gtk.Notebook() notebook.set_tab_pos(position) notebook.set_show_border(True) return notebook
[ "def", "create_notebook", "(", "self", ",", "position", "=", "Gtk", ".", "PositionType", ".", "TOP", ")", ":", "notebook", "=", "Gtk", ".", "Notebook", "(", ")", "notebook", ".", "set_tab_pos", "(", "position", ")", "notebook", ".", "set_show_border", "(",...
Function creates a notebook
[ "Function", "creates", "a", "notebook" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L350-L357
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_message_dialog
def create_message_dialog(self, text, buttons=Gtk.ButtonsType.CLOSE, icon=Gtk.MessageType.WARNING): """ Function creates a message dialog with text and relevant buttons """ dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, ...
python
def create_message_dialog(self, text, buttons=Gtk.ButtonsType.CLOSE, icon=Gtk.MessageType.WARNING): """ Function creates a message dialog with text and relevant buttons """ dialog = Gtk.MessageDialog(None, Gtk.DialogFlags.DESTROY_WITH_PARENT, ...
[ "def", "create_message_dialog", "(", "self", ",", "text", ",", "buttons", "=", "Gtk", ".", "ButtonsType", ".", "CLOSE", ",", "icon", "=", "Gtk", ".", "MessageType", ".", "WARNING", ")", ":", "dialog", "=", "Gtk", ".", "MessageDialog", "(", "None", ",", ...
Function creates a message dialog with text and relevant buttons
[ "Function", "creates", "a", "message", "dialog", "with", "text", "and", "relevant", "buttons" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L359-L370
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_question_dialog
def create_question_dialog(self, text, second_text): """ Function creates a question dialog with title text and second_text """ dialog = self.create_message_dialog( text, buttons=Gtk.ButtonsType.YES_NO, icon=Gtk.MessageType.QUESTION ) dialog.format_sec...
python
def create_question_dialog(self, text, second_text): """ Function creates a question dialog with title text and second_text """ dialog = self.create_message_dialog( text, buttons=Gtk.ButtonsType.YES_NO, icon=Gtk.MessageType.QUESTION ) dialog.format_sec...
[ "def", "create_question_dialog", "(", "self", ",", "text", ",", "second_text", ")", ":", "dialog", "=", "self", ".", "create_message_dialog", "(", "text", ",", "buttons", "=", "Gtk", ".", "ButtonsType", ".", "YES_NO", ",", "icon", "=", "Gtk", ".", "Message...
Function creates a question dialog with title text and second_text
[ "Function", "creates", "a", "question", "dialog", "with", "title", "text", "and", "second_text" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L372-L383
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.execute_dialog
def execute_dialog(self, title): """ Function executes a dialog """ msg_dlg = self.create_message_dialog(title) msg_dlg.run() msg_dlg.destroy() return
python
def execute_dialog(self, title): """ Function executes a dialog """ msg_dlg = self.create_message_dialog(title) msg_dlg.run() msg_dlg.destroy() return
[ "def", "execute_dialog", "(", "self", ",", "title", ")", ":", "msg_dlg", "=", "self", ".", "create_message_dialog", "(", "title", ")", "msg_dlg", ".", "run", "(", ")", "msg_dlg", ".", "destroy", "(", ")", "return" ]
Function executes a dialog
[ "Function", "executes", "a", "dialog" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L385-L392
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_file_chooser_dialog
def create_file_chooser_dialog(self, text, parent, name=Gtk.STOCK_OPEN): """ Function creates a file chooser dialog with title text """ text = None dialog = Gtk.FileChooserDialog( text, parent, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CA...
python
def create_file_chooser_dialog(self, text, parent, name=Gtk.STOCK_OPEN): """ Function creates a file chooser dialog with title text """ text = None dialog = Gtk.FileChooserDialog( text, parent, Gtk.FileChooserAction.SELECT_FOLDER, (Gtk.STOCK_CA...
[ "def", "create_file_chooser_dialog", "(", "self", ",", "text", ",", "parent", ",", "name", "=", "Gtk", ".", "STOCK_OPEN", ")", ":", "text", "=", "None", "dialog", "=", "Gtk", ".", "FileChooserDialog", "(", "text", ",", "parent", ",", "Gtk", ".", "FileCho...
Function creates a file chooser dialog with title text
[ "Function", "creates", "a", "file", "chooser", "dialog", "with", "title", "text" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L394-L408
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_alignment
def create_alignment(self, x_align=0, y_align=0, x_scale=0, y_scale=0): """ Function creates an alignment """ align = Gtk.Alignment() align.set(x_align, y_align, x_scale, y_scale) return align
python
def create_alignment(self, x_align=0, y_align=0, x_scale=0, y_scale=0): """ Function creates an alignment """ align = Gtk.Alignment() align.set(x_align, y_align, x_scale, y_scale) return align
[ "def", "create_alignment", "(", "self", ",", "x_align", "=", "0", ",", "y_align", "=", "0", ",", "x_scale", "=", "0", ",", "y_scale", "=", "0", ")", ":", "align", "=", "Gtk", ".", "Alignment", "(", ")", "align", ".", "set", "(", "x_align", ",", "...
Function creates an alignment
[ "Function", "creates", "an", "alignment" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L410-L416
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_textview
def create_textview(self, wrap_mode=Gtk.WrapMode.WORD_CHAR, justify=Gtk.Justification.LEFT, visible=True, editable=True): """ Function creates a text view with wrap_mode and justification """ text_view = Gtk.TextView() text_view.set_wrap_mode(wrap_mode) text_view....
python
def create_textview(self, wrap_mode=Gtk.WrapMode.WORD_CHAR, justify=Gtk.Justification.LEFT, visible=True, editable=True): """ Function creates a text view with wrap_mode and justification """ text_view = Gtk.TextView() text_view.set_wrap_mode(wrap_mode) text_view....
[ "def", "create_textview", "(", "self", ",", "wrap_mode", "=", "Gtk", ".", "WrapMode", ".", "WORD_CHAR", ",", "justify", "=", "Gtk", ".", "Justification", ".", "LEFT", ",", "visible", "=", "True", ",", "editable", "=", "True", ")", ":", "text_view", "=", ...
Function creates a text view with wrap_mode and justification
[ "Function", "creates", "a", "text", "view", "with", "wrap_mode", "and", "justification" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L418-L431
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_tree_view
def create_tree_view(self, model=None): """ Function creates a tree_view with model """ tree_view = Gtk.TreeView() if model is not None: tree_view.set_model(model) return tree_view
python
def create_tree_view(self, model=None): """ Function creates a tree_view with model """ tree_view = Gtk.TreeView() if model is not None: tree_view.set_model(model) return tree_view
[ "def", "create_tree_view", "(", "self", ",", "model", "=", "None", ")", ":", "tree_view", "=", "Gtk", ".", "TreeView", "(", ")", "if", "model", "is", "not", "None", ":", "tree_view", ".", "set_model", "(", "model", ")", "return", "tree_view" ]
Function creates a tree_view with model
[ "Function", "creates", "a", "tree_view", "with", "model" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L433-L440
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_cell_renderer_text
def create_cell_renderer_text(self, tree_view, title="title", assign=0, editable=False): """ Function creates a CellRendererText with title """ renderer = Gtk.CellRendererText() renderer.set_property('editable', editable) column = Gtk.TreeViewColumn(title, renderer, text=...
python
def create_cell_renderer_text(self, tree_view, title="title", assign=0, editable=False): """ Function creates a CellRendererText with title """ renderer = Gtk.CellRendererText() renderer.set_property('editable', editable) column = Gtk.TreeViewColumn(title, renderer, text=...
[ "def", "create_cell_renderer_text", "(", "self", ",", "tree_view", ",", "title", "=", "\"title\"", ",", "assign", "=", "0", ",", "editable", "=", "False", ")", ":", "renderer", "=", "Gtk", ".", "CellRendererText", "(", ")", "renderer", ".", "set_property", ...
Function creates a CellRendererText with title
[ "Function", "creates", "a", "CellRendererText", "with", "title" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L442-L449
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_cell_renderer_combo
def create_cell_renderer_combo(self, tree_view, title="title", assign=0, editable=False, model=None, function=None): """' Function creates a CellRendererCombo with title, model """ renderer_combo = Gtk.CellRendererCombo() renderer_combo.set_property('editable', editable) ...
python
def create_cell_renderer_combo(self, tree_view, title="title", assign=0, editable=False, model=None, function=None): """' Function creates a CellRendererCombo with title, model """ renderer_combo = Gtk.CellRendererCombo() renderer_combo.set_property('editable', editable) ...
[ "def", "create_cell_renderer_combo", "(", "self", ",", "tree_view", ",", "title", "=", "\"title\"", ",", "assign", "=", "0", ",", "editable", "=", "False", ",", "model", "=", "None", ",", "function", "=", "None", ")", ":", "renderer_combo", "=", "Gtk", "...
Function creates a CellRendererCombo with title, model
[ "Function", "creates", "a", "CellRendererCombo", "with", "title", "model" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L451-L464
devassistant/devassistant
devassistant/gui/gui_helper.py
GuiHelper.create_clipboard
def create_clipboard(self, text, selection=Gdk.SELECTION_CLIPBOARD): """ Function creates a clipboard """ clipboard = Gtk.Clipboard.get(selection) clipboard.set_text('\n'.join(text), -1) clipboard.store() return clipboard
python
def create_clipboard(self, text, selection=Gdk.SELECTION_CLIPBOARD): """ Function creates a clipboard """ clipboard = Gtk.Clipboard.get(selection) clipboard.set_text('\n'.join(text), -1) clipboard.store() return clipboard
[ "def", "create_clipboard", "(", "self", ",", "text", ",", "selection", "=", "Gdk", ".", "SELECTION_CLIPBOARD", ")", ":", "clipboard", "=", "Gtk", ".", "Clipboard", ".", "get", "(", "selection", ")", "clipboard", ".", "set_text", "(", "'\\n'", ".", "join", ...
Function creates a clipboard
[ "Function", "creates", "a", "clipboard" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L466-L473
devassistant/devassistant
devassistant/command_helpers.py
ClHelper.run_command
def run_command(cls, cmd_str, log_level=logging.DEBUG, ignore_sigint=False, output_callback=None, as_user=None, log_secret=False, env=None): """Runs a command from string, ...
python
def run_command(cls, cmd_str, log_level=logging.DEBUG, ignore_sigint=False, output_callback=None, as_user=None, log_secret=False, env=None): """Runs a command from string, ...
[ "def", "run_command", "(", "cls", ",", "cmd_str", ",", "log_level", "=", "logging", ".", "DEBUG", ",", "ignore_sigint", "=", "False", ",", "output_callback", "=", "None", ",", "as_user", "=", "None", ",", "log_secret", "=", "False", ",", "env", "=", "Non...
Runs a command from string, e.g. "cp foo bar" Args: cmd_str: the command to run as string log_level: level at which to log command output (DEBUG by default) ignore_sigint: should we ignore sigint during this command (False by default) output_callback: function tha...
[ "Runs", "a", "command", "from", "string", "e", ".", "g", ".", "cp", "foo", "bar", "Args", ":", "cmd_str", ":", "the", "command", "to", "run", "as", "string", "log_level", ":", "level", "at", "which", "to", "log", "command", "output", "(", "DEBUG", "b...
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/command_helpers.py#L32-L133
devassistant/devassistant
devassistant/command_helpers.py
DialogHelper.ask_for_password
def ask_for_password(cls, ui, prompt='Provide your password:', **options): """Returns the password typed by user as a string or None if user cancels the request (e.g. presses Ctrl + D on commandline or presses Cancel in GUI. """ # optionally set title, that may be used by some helpers li...
python
def ask_for_password(cls, ui, prompt='Provide your password:', **options): """Returns the password typed by user as a string or None if user cancels the request (e.g. presses Ctrl + D on commandline or presses Cancel in GUI. """ # optionally set title, that may be used by some helpers li...
[ "def", "ask_for_password", "(", "cls", ",", "ui", ",", "prompt", "=", "'Provide your password:'", ",", "*", "*", "options", ")", ":", "# optionally set title, that may be used by some helpers like zenity", "return", "cls", ".", "get_appropriate_helper", "(", "ui", ")", ...
Returns the password typed by user as a string or None if user cancels the request (e.g. presses Ctrl + D on commandline or presses Cancel in GUI.
[ "Returns", "the", "password", "typed", "by", "user", "as", "a", "string", "or", "None", "if", "user", "cancels", "the", "request", "(", "e", ".", "g", ".", "presses", "Ctrl", "+", "D", "on", "commandline", "or", "presses", "Cancel", "in", "GUI", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/command_helpers.py#L226-L232
devassistant/devassistant
devassistant/command_helpers.py
DialogHelper.ask_for_confirm_with_message
def ask_for_confirm_with_message(cls, ui, prompt='Do you agree?', message='', **options): """Returns True if user agrees, False otherwise""" return cls.get_appropriate_helper(ui).ask_for_confirm_with_message(prompt, message)
python
def ask_for_confirm_with_message(cls, ui, prompt='Do you agree?', message='', **options): """Returns True if user agrees, False otherwise""" return cls.get_appropriate_helper(ui).ask_for_confirm_with_message(prompt, message)
[ "def", "ask_for_confirm_with_message", "(", "cls", ",", "ui", ",", "prompt", "=", "'Do you agree?'", ",", "message", "=", "''", ",", "*", "*", "options", ")", ":", "return", "cls", ".", "get_appropriate_helper", "(", "ui", ")", ".", "ask_for_confirm_with_messa...
Returns True if user agrees, False otherwise
[ "Returns", "True", "if", "user", "agrees", "False", "otherwise" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/command_helpers.py#L235-L237
devassistant/devassistant
devassistant/command_helpers.py
DialogHelper.ask_for_input_with_prompt
def ask_for_input_with_prompt(cls, ui, prompt='', **options): """Ask user for written input with prompt""" return cls.get_appropriate_helper(ui).ask_for_input_with_prompt(prompt=prompt, **options)
python
def ask_for_input_with_prompt(cls, ui, prompt='', **options): """Ask user for written input with prompt""" return cls.get_appropriate_helper(ui).ask_for_input_with_prompt(prompt=prompt, **options)
[ "def", "ask_for_input_with_prompt", "(", "cls", ",", "ui", ",", "prompt", "=", "''", ",", "*", "*", "options", ")", ":", "return", "cls", ".", "get_appropriate_helper", "(", "ui", ")", ".", "ask_for_input_with_prompt", "(", "prompt", "=", "prompt", ",", "*...
Ask user for written input with prompt
[ "Ask", "user", "for", "written", "input", "with", "prompt" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/command_helpers.py#L250-L252
devassistant/devassistant
devassistant/argument.py
Argument.add_argument_to
def add_argument_to(self, parser): """Used by cli to add this as an argument to argparse parser. Args: parser: parser to add this argument to """ from devassistant.cli.devassistant_argparse import DefaultIffUsedActionFactory if isinstance(self.kwargs.get('action', ''...
python
def add_argument_to(self, parser): """Used by cli to add this as an argument to argparse parser. Args: parser: parser to add this argument to """ from devassistant.cli.devassistant_argparse import DefaultIffUsedActionFactory if isinstance(self.kwargs.get('action', ''...
[ "def", "add_argument_to", "(", "self", ",", "parser", ")", ":", "from", "devassistant", ".", "cli", ".", "devassistant_argparse", "import", "DefaultIffUsedActionFactory", "if", "isinstance", "(", "self", ".", "kwargs", ".", "get", "(", "'action'", ",", "''", "...
Used by cli to add this as an argument to argparse parser. Args: parser: parser to add this argument to
[ "Used", "by", "cli", "to", "add", "this", "as", "an", "argument", "to", "argparse", "parser", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/argument.py#L34-L54
devassistant/devassistant
devassistant/argument.py
Argument.get_gui_hint
def get_gui_hint(self, hint): """Returns the value for specified gui hint (or a sensible default value, if this argument doesn't specify the hint). Args: hint: name of the hint to get value for Returns: value of the hint specified in yaml or a sensible default ...
python
def get_gui_hint(self, hint): """Returns the value for specified gui hint (or a sensible default value, if this argument doesn't specify the hint). Args: hint: name of the hint to get value for Returns: value of the hint specified in yaml or a sensible default ...
[ "def", "get_gui_hint", "(", "self", ",", "hint", ")", ":", "if", "hint", "==", "'type'", ":", "# 'self.kwargs.get('nargs') == 0' is there for default_iff_used, which may", "# have nargs: 0, so that it works similarly to 'store_const'", "if", "self", ".", "kwargs", ".", "get",...
Returns the value for specified gui hint (or a sensible default value, if this argument doesn't specify the hint). Args: hint: name of the hint to get value for Returns: value of the hint specified in yaml or a sensible default
[ "Returns", "the", "value", "for", "specified", "gui", "hint", "(", "or", "a", "sensible", "default", "value", "if", "this", "argument", "doesn", "t", "specify", "the", "hint", ")", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/argument.py#L67-L108
devassistant/devassistant
devassistant/argument.py
Argument.construct_arg
def construct_arg(cls, name, params): """Construct an argument from name, and params (dict loaded from assistant/snippet). """ use_snippet = params.pop('use', None) if use_snippet: # if snippet is used, take this parameter from snippet and update # it with current...
python
def construct_arg(cls, name, params): """Construct an argument from name, and params (dict loaded from assistant/snippet). """ use_snippet = params.pop('use', None) if use_snippet: # if snippet is used, take this parameter from snippet and update # it with current...
[ "def", "construct_arg", "(", "cls", ",", "name", ",", "params", ")", ":", "use_snippet", "=", "params", ".", "pop", "(", "'use'", ",", "None", ")", "if", "use_snippet", ":", "# if snippet is used, take this parameter from snippet and update", "# it with current params...
Construct an argument from name, and params (dict loaded from assistant/snippet).
[ "Construct", "an", "argument", "from", "name", "and", "params", "(", "dict", "loaded", "from", "assistant", "/", "snippet", ")", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/argument.py#L111-L133
devassistant/devassistant
devassistant/assistant_base.py
AssistantBase.get_subassistants
def get_subassistants(self): """Return list of instantiated subassistants. Usually, this needs not be overriden in subclasses, you should just override get_subassistant_classes Returns: list of instantiated subassistants """ if not hasattr(self, '_subassista...
python
def get_subassistants(self): """Return list of instantiated subassistants. Usually, this needs not be overriden in subclasses, you should just override get_subassistant_classes Returns: list of instantiated subassistants """ if not hasattr(self, '_subassista...
[ "def", "get_subassistants", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_subassistants'", ")", ":", "self", ".", "_subassistants", "=", "[", "]", "# we want to know, if type(self) defines 'get_subassistant_classes',", "# we don't want to inherit it ...
Return list of instantiated subassistants. Usually, this needs not be overriden in subclasses, you should just override get_subassistant_classes Returns: list of instantiated subassistants
[ "Return", "list", "of", "instantiated", "subassistants", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/assistant_base.py#L33-L49
devassistant/devassistant
devassistant/assistant_base.py
AssistantBase.get_subassistant_tree
def get_subassistant_tree(self): """Returns a tree-like structure representing the assistant hierarchy going down from this assistant to leaf assistants. For example: [(<This Assistant>, [(<Subassistant 1>, [...]), (<Subassistant 2>, [...])] ...
python
def get_subassistant_tree(self): """Returns a tree-like structure representing the assistant hierarchy going down from this assistant to leaf assistants. For example: [(<This Assistant>, [(<Subassistant 1>, [...]), (<Subassistant 2>, [...])] ...
[ "def", "get_subassistant_tree", "(", "self", ")", ":", "if", "'_tree'", "not", "in", "dir", "(", "self", ")", ":", "subassistant_tree", "=", "[", "]", "subassistants", "=", "self", ".", "get_subassistants", "(", ")", "for", "subassistant", "in", "subassistan...
Returns a tree-like structure representing the assistant hierarchy going down from this assistant to leaf assistants. For example: [(<This Assistant>, [(<Subassistant 1>, [...]), (<Subassistant 2>, [...])] )] Returns: ...
[ "Returns", "a", "tree", "-", "like", "structure", "representing", "the", "assistant", "hierarchy", "going", "down", "from", "this", "assistant", "to", "leaf", "assistants", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/assistant_base.py#L51-L69
devassistant/devassistant
devassistant/assistant_base.py
AssistantBase.get_selected_subassistant_path
def get_selected_subassistant_path(self, **kwargs): """Recursively searches self._tree - has format of (Assistant: [list_of_subassistants]) - for specific path from first to last selected subassistants. Args: kwargs: arguments containing names of the given assistants in form of ...
python
def get_selected_subassistant_path(self, **kwargs): """Recursively searches self._tree - has format of (Assistant: [list_of_subassistants]) - for specific path from first to last selected subassistants. Args: kwargs: arguments containing names of the given assistants in form of ...
[ "def", "get_selected_subassistant_path", "(", "self", ",", "*", "*", "kwargs", ")", ":", "path", "=", "[", "self", "]", "previous_subas_list", "=", "None", "currently_searching", "=", "self", ".", "get_subassistant_tree", "(", ")", "[", "1", "]", "# len(path) ...
Recursively searches self._tree - has format of (Assistant: [list_of_subassistants]) - for specific path from first to last selected subassistants. Args: kwargs: arguments containing names of the given assistants in form of subassistant_0 = 'name', subassistant_1 = 'another_name...
[ "Recursively", "searches", "self", ".", "_tree", "-", "has", "format", "of", "(", "Assistant", ":", "[", "list_of_subassistants", "]", ")", "-", "for", "specific", "path", "from", "first", "to", "last", "selected", "subassistants", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/assistant_base.py#L71-L101
devassistant/devassistant
devassistant/assistant_base.py
AssistantBase.is_run_as_leaf
def is_run_as_leaf(self, **kwargs): """Returns True if this assistant was run as last in path, False otherwise.""" # find the last subassistant_N i = 0 while i < len(kwargs): # len(kwargs) is maximum of subassistant_N keys if settings.SUBASSISTANT_N_STRING.format(i) in kwarg...
python
def is_run_as_leaf(self, **kwargs): """Returns True if this assistant was run as last in path, False otherwise.""" # find the last subassistant_N i = 0 while i < len(kwargs): # len(kwargs) is maximum of subassistant_N keys if settings.SUBASSISTANT_N_STRING.format(i) in kwarg...
[ "def", "is_run_as_leaf", "(", "self", ",", "*", "*", "kwargs", ")", ":", "# find the last subassistant_N", "i", "=", "0", "while", "i", "<", "len", "(", "kwargs", ")", ":", "# len(kwargs) is maximum of subassistant_N keys", "if", "settings", ".", "SUBASSISTANT_N_S...
Returns True if this assistant was run as last in path, False otherwise.
[ "Returns", "True", "if", "this", "assistant", "was", "run", "as", "last", "in", "path", "False", "otherwise", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/assistant_base.py#L103-L112
devassistant/devassistant
devassistant/yaml_loader.py
YamlLoader.load_all_yamls
def load_all_yamls(cls, directories): """Loads yaml files from all given directories. Args: directories: list of directories to search Returns: dict of {fullpath: loaded_yaml_structure} """ yaml_files = [] loaded_yamls = {} for d in direc...
python
def load_all_yamls(cls, directories): """Loads yaml files from all given directories. Args: directories: list of directories to search Returns: dict of {fullpath: loaded_yaml_structure} """ yaml_files = [] loaded_yamls = {} for d in direc...
[ "def", "load_all_yamls", "(", "cls", ",", "directories", ")", ":", "yaml_files", "=", "[", "]", "loaded_yamls", "=", "{", "}", "for", "d", "in", "directories", ":", "if", "d", ".", "startswith", "(", "'/home'", ")", "and", "not", "os", ".", "path", "...
Loads yaml files from all given directories. Args: directories: list of directories to search Returns: dict of {fullpath: loaded_yaml_structure}
[ "Loads", "yaml", "files", "from", "all", "given", "directories", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_loader.py#L17-L38
devassistant/devassistant
devassistant/yaml_loader.py
YamlLoader.load_yaml_by_relpath
def load_yaml_by_relpath(cls, directories, rel_path, log_debug=False): """Load a yaml file with path that is relative to one of given directories. Args: directories: list of directories to search name: relative path of the yaml file to load log_debug: log all message...
python
def load_yaml_by_relpath(cls, directories, rel_path, log_debug=False): """Load a yaml file with path that is relative to one of given directories. Args: directories: list of directories to search name: relative path of the yaml file to load log_debug: log all message...
[ "def", "load_yaml_by_relpath", "(", "cls", ",", "directories", ",", "rel_path", ",", "log_debug", "=", "False", ")", ":", "for", "d", "in", "directories", ":", "if", "d", ".", "startswith", "(", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", ")...
Load a yaml file with path that is relative to one of given directories. Args: directories: list of directories to search name: relative path of the yaml file to load log_debug: log all messages as debug Returns: tuple (fullpath, loaded yaml structure) or...
[ "Load", "a", "yaml", "file", "with", "path", "that", "is", "relative", "to", "one", "of", "given", "directories", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_loader.py#L41-L60
devassistant/devassistant
devassistant/yaml_loader.py
YamlLoader.load_yaml_by_path
def load_yaml_by_path(cls, path, log_debug=False): """Load a yaml file that is at given path, if the path is not a string, it is assumed it's a file-like object""" try: if isinstance(path, six.string_types): return yaml.load(open(path, 'r'), Loader=Loader) or {} ...
python
def load_yaml_by_path(cls, path, log_debug=False): """Load a yaml file that is at given path, if the path is not a string, it is assumed it's a file-like object""" try: if isinstance(path, six.string_types): return yaml.load(open(path, 'r'), Loader=Loader) or {} ...
[ "def", "load_yaml_by_path", "(", "cls", ",", "path", ",", "log_debug", "=", "False", ")", ":", "try", ":", "if", "isinstance", "(", "path", ",", "six", ".", "string_types", ")", ":", "return", "yaml", ".", "load", "(", "open", "(", "path", ",", "'r'"...
Load a yaml file that is at given path, if the path is not a string, it is assumed it's a file-like object
[ "Load", "a", "yaml", "file", "that", "is", "at", "given", "path", "if", "the", "path", "is", "not", "a", "string", "it", "is", "assumed", "it", "s", "a", "file", "-", "like", "object" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/yaml_loader.py#L63-L78
devassistant/devassistant
devassistant/path_runner.py
PathRunner._run_path_dependencies
def _run_path_dependencies(self, parsed_args): """Installs dependencies from the leaf assistant. Raises: devassistant.exceptions.DependencyException with a cause if something goes wrong """ deps = self.path[-1].dependencies(parsed_args) lang.Command('dependencies', d...
python
def _run_path_dependencies(self, parsed_args): """Installs dependencies from the leaf assistant. Raises: devassistant.exceptions.DependencyException with a cause if something goes wrong """ deps = self.path[-1].dependencies(parsed_args) lang.Command('dependencies', d...
[ "def", "_run_path_dependencies", "(", "self", ",", "parsed_args", ")", ":", "deps", "=", "self", ".", "path", "[", "-", "1", "]", ".", "dependencies", "(", "parsed_args", ")", "lang", ".", "Command", "(", "'dependencies'", ",", "deps", ",", "parsed_args", ...
Installs dependencies from the leaf assistant. Raises: devassistant.exceptions.DependencyException with a cause if something goes wrong
[ "Installs", "dependencies", "from", "the", "leaf", "assistant", ".", "Raises", ":", "devassistant", ".", "exceptions", ".", "DependencyException", "with", "a", "cause", "if", "something", "goes", "wrong" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/path_runner.py#L19-L26
devassistant/devassistant
devassistant/path_runner.py
PathRunner.run
def run(self): """Runs all errors, dependencies and run methods of all *Assistant objects in self.path. Raises: devassistant.exceptions.ExecutionException with a cause if something goes wrong """ error = None # run 'pre_run', 'logging', 'dependencies' and 'run' ...
python
def run(self): """Runs all errors, dependencies and run methods of all *Assistant objects in self.path. Raises: devassistant.exceptions.ExecutionException with a cause if something goes wrong """ error = None # run 'pre_run', 'logging', 'dependencies' and 'run' ...
[ "def", "run", "(", "self", ")", ":", "error", "=", "None", "# run 'pre_run', 'logging', 'dependencies' and 'run'", "try", ":", "# serve as a central place for error logging", "self", ".", "_logging", "(", "self", ".", "parsed_args", ")", "if", "'deps_only'", "not", "i...
Runs all errors, dependencies and run methods of all *Assistant objects in self.path. Raises: devassistant.exceptions.ExecutionException with a cause if something goes wrong
[ "Runs", "all", "errors", "dependencies", "and", "run", "methods", "of", "all", "*", "Assistant", "objects", "in", "self", ".", "path", ".", "Raises", ":", "devassistant", ".", "exceptions", ".", "ExecutionException", "with", "a", "cause", "if", "something", ...
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/path_runner.py#L42-L75
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter.calculate_offset
def calculate_offset(cls, labels): '''Return the maximum length of the provided strings that have a nice variant in DapFormatter._nice_strings''' used_strings = set(cls._nice_strings.keys()) & set(labels) return max([len(cls._nice_strings[s]) for s in used_strings])
python
def calculate_offset(cls, labels): '''Return the maximum length of the provided strings that have a nice variant in DapFormatter._nice_strings''' used_strings = set(cls._nice_strings.keys()) & set(labels) return max([len(cls._nice_strings[s]) for s in used_strings])
[ "def", "calculate_offset", "(", "cls", ",", "labels", ")", ":", "used_strings", "=", "set", "(", "cls", ".", "_nice_strings", ".", "keys", "(", ")", ")", "&", "set", "(", "labels", ")", "return", "max", "(", "[", "len", "(", "cls", ".", "_nice_string...
Return the maximum length of the provided strings that have a nice variant in DapFormatter._nice_strings
[ "Return", "the", "maximum", "length", "of", "the", "provided", "strings", "that", "have", "a", "nice", "variant", "in", "DapFormatter", ".", "_nice_strings" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L57-L61
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter.format_dapi_score
def format_dapi_score(cls, meta, offset): '''Format the line with DAPI user rating and number of votes''' if 'average_rank' and 'rank_count' in meta: label = (cls._nice_strings['average_rank'] + ':').ljust(offset + 2) score = cls._format_field(meta['average_rank']) vo...
python
def format_dapi_score(cls, meta, offset): '''Format the line with DAPI user rating and number of votes''' if 'average_rank' and 'rank_count' in meta: label = (cls._nice_strings['average_rank'] + ':').ljust(offset + 2) score = cls._format_field(meta['average_rank']) vo...
[ "def", "format_dapi_score", "(", "cls", ",", "meta", ",", "offset", ")", ":", "if", "'average_rank'", "and", "'rank_count'", "in", "meta", ":", "label", "=", "(", "cls", ".", "_nice_strings", "[", "'average_rank'", "]", "+", "':'", ")", ".", "ljust", "("...
Format the line with DAPI user rating and number of votes
[ "Format", "the", "line", "with", "DAPI", "user", "rating", "and", "number", "of", "votes" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L64-L72
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter.format_meta_lines
def format_meta_lines(cls, meta, labels, offset, **kwargs): '''Return all information from a given meta dictionary in a list of lines''' lines = [] # Name and underline name = meta['package_name'] if 'version' in meta: name += '-' + meta['version'] if 'custom...
python
def format_meta_lines(cls, meta, labels, offset, **kwargs): '''Return all information from a given meta dictionary in a list of lines''' lines = [] # Name and underline name = meta['package_name'] if 'version' in meta: name += '-' + meta['version'] if 'custom...
[ "def", "format_meta_lines", "(", "cls", ",", "meta", ",", "labels", ",", "offset", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "[", "]", "# Name and underline", "name", "=", "meta", "[", "'package_name'", "]", "if", "'version'", "in", "meta", ":", ...
Return all information from a given meta dictionary in a list of lines
[ "Return", "all", "information", "from", "a", "given", "meta", "dictionary", "in", "a", "list", "of", "lines" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L75-L109
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter._format_files
def _format_files(cls, files, kind): '''Format the list of files (e. g. assistants or snippets''' lines = [] if files: lines.append('The following {kind} are contained in this DAP:'.format(kind=kind.title())) for f in files: lines.append('* ' + strip_prefi...
python
def _format_files(cls, files, kind): '''Format the list of files (e. g. assistants or snippets''' lines = [] if files: lines.append('The following {kind} are contained in this DAP:'.format(kind=kind.title())) for f in files: lines.append('* ' + strip_prefi...
[ "def", "_format_files", "(", "cls", ",", "files", ",", "kind", ")", ":", "lines", "=", "[", "]", "if", "files", ":", "lines", ".", "append", "(", "'The following {kind} are contained in this DAP:'", ".", "format", "(", "kind", "=", "kind", ".", "title", "(...
Format the list of files (e. g. assistants or snippets
[ "Format", "the", "list", "of", "files", "(", "e", ".", "g", ".", "assistants", "or", "snippets" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L112-L121
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter.format_assistants_lines
def format_assistants_lines(cls, assistants): '''Return formatted assistants from the given list in human readable form.''' lines = cls._format_files(assistants, 'assistants') # Assistant help if assistants: lines.append('') assistant = strip_prefix(random.choice...
python
def format_assistants_lines(cls, assistants): '''Return formatted assistants from the given list in human readable form.''' lines = cls._format_files(assistants, 'assistants') # Assistant help if assistants: lines.append('') assistant = strip_prefix(random.choice...
[ "def", "format_assistants_lines", "(", "cls", ",", "assistants", ")", ":", "lines", "=", "cls", ".", "_format_files", "(", "assistants", ",", "'assistants'", ")", "# Assistant help", "if", "assistants", ":", "lines", ".", "append", "(", "''", ")", "assistant",...
Return formatted assistants from the given list in human readable form.
[ "Return", "formatted", "assistants", "from", "the", "given", "list", "in", "human", "readable", "form", "." ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L124-L140
devassistant/devassistant
devassistant/dapi/__init__.py
DapFormatter.format_platforms
def format_platforms(cls, platforms): '''Formats supported platforms in human readable form''' lines = [] if platforms: lines.append('This DAP is only supported on the following platforms:') lines.extend([' * ' + platform for platform in platforms]) return lines
python
def format_platforms(cls, platforms): '''Formats supported platforms in human readable form''' lines = [] if platforms: lines.append('This DAP is only supported on the following platforms:') lines.extend([' * ' + platform for platform in platforms]) return lines
[ "def", "format_platforms", "(", "cls", ",", "platforms", ")", ":", "lines", "=", "[", "]", "if", "platforms", ":", "lines", ".", "append", "(", "'This DAP is only supported on the following platforms:'", ")", "lines", ".", "extend", "(", "[", "' * '", "+", "pl...
Formats supported platforms in human readable form
[ "Formats", "supported", "platforms", "in", "human", "readable", "form" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L148-L154
devassistant/devassistant
devassistant/dapi/__init__.py
DapChecker.check
def check(cls, dap, network=False, yamls=True, raises=False, logger=logger): '''Checks if the dap is valid, reports problems Parameters: network -- whether to run checks that requires network connection output -- where to write() problems, might be None raises -- whe...
python
def check(cls, dap, network=False, yamls=True, raises=False, logger=logger): '''Checks if the dap is valid, reports problems Parameters: network -- whether to run checks that requires network connection output -- where to write() problems, might be None raises -- whe...
[ "def", "check", "(", "cls", ",", "dap", ",", "network", "=", "False", ",", "yamls", "=", "True", ",", "raises", "=", "False", ",", "logger", "=", "logger", ")", ":", "dap", ".", "_check_raises", "=", "raises", "dap", ".", "_problematic", "=", "False"...
Checks if the dap is valid, reports problems Parameters: network -- whether to run checks that requires network connection output -- where to write() problems, might be None raises -- whether to raise an exception immediately after problem is detected
[ "Checks", "if", "the", "dap", "is", "valid", "reports", "problems" ]
train
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/__init__.py#L160-L187