repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
NASA-AMMOS/AIT-Core
ait/core/api.py
UdpTelemetryServer.start
def start (self): """Starts this UdpTelemetryServer.""" values = self._defn.name, self.server_host, self.server_port log.info('Listening for %s telemetry on %s:%d (UDP)' % values) super(UdpTelemetryServer, self).start()
python
def start (self): """Starts this UdpTelemetryServer.""" values = self._defn.name, self.server_host, self.server_port log.info('Listening for %s telemetry on %s:%d (UDP)' % values) super(UdpTelemetryServer, self).start()
[ "def", "start", "(", "self", ")", ":", "values", "=", "self", ".", "_defn", ".", "name", ",", "self", ".", "server_host", ",", "self", ".", "server_port", "log", ".", "info", "(", "'Listening for %s telemetry on %s:%d (UDP)'", "%", "values", ")", "super", ...
Starts this UdpTelemetryServer.
[ "Starts", "this", "UdpTelemetryServer", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L455-L459
train
42,800
NASA-AMMOS/AIT-Core
ait/core/api.py
UIAPI.msgBox
def msgBox(self, promptType, _timeout=-1, **options): ''' Send a user prompt request to the GUI Arguments: promptType (string): The prompt type to send to the GUI. Currently the only type supported is 'confirm'. _timeout (int): The optional amount of time for which the prompt should be displayed to the user before a timeout occurs. Defaults to -1 which indicates there is no timeout limit. options (dict): The keyword arguments that should be passed to the requested prompt type. Check prompt specific sections below for information on what arguments are expected to be present. Raises: ValueError: If the prompt type received is an unexpected value **Confirm Prompt** Display a message to the user and prompt them for a confirm/deny response to the message. Arguments: msg (string): The message to display to the user Returns: True if the user picks 'Confirm', False if the user picks 'Deny' Raises: KeyError: If the options passed to the prompt handler doesn't contain a `msg` attribute. APITimeoutError: If the timeout value is reached without receiving a response. ''' if promptType == 'confirm': return self._sendConfirmPrompt(_timeout, options) else: raise ValueError('Unknown prompt type: {}'.format(promptType))
python
def msgBox(self, promptType, _timeout=-1, **options): ''' Send a user prompt request to the GUI Arguments: promptType (string): The prompt type to send to the GUI. Currently the only type supported is 'confirm'. _timeout (int): The optional amount of time for which the prompt should be displayed to the user before a timeout occurs. Defaults to -1 which indicates there is no timeout limit. options (dict): The keyword arguments that should be passed to the requested prompt type. Check prompt specific sections below for information on what arguments are expected to be present. Raises: ValueError: If the prompt type received is an unexpected value **Confirm Prompt** Display a message to the user and prompt them for a confirm/deny response to the message. Arguments: msg (string): The message to display to the user Returns: True if the user picks 'Confirm', False if the user picks 'Deny' Raises: KeyError: If the options passed to the prompt handler doesn't contain a `msg` attribute. APITimeoutError: If the timeout value is reached without receiving a response. ''' if promptType == 'confirm': return self._sendConfirmPrompt(_timeout, options) else: raise ValueError('Unknown prompt type: {}'.format(promptType))
[ "def", "msgBox", "(", "self", ",", "promptType", ",", "_timeout", "=", "-", "1", ",", "*", "*", "options", ")", ":", "if", "promptType", "==", "'confirm'", ":", "return", "self", ".", "_sendConfirmPrompt", "(", "_timeout", ",", "options", ")", "else", ...
Send a user prompt request to the GUI Arguments: promptType (string): The prompt type to send to the GUI. Currently the only type supported is 'confirm'. _timeout (int): The optional amount of time for which the prompt should be displayed to the user before a timeout occurs. Defaults to -1 which indicates there is no timeout limit. options (dict): The keyword arguments that should be passed to the requested prompt type. Check prompt specific sections below for information on what arguments are expected to be present. Raises: ValueError: If the prompt type received is an unexpected value **Confirm Prompt** Display a message to the user and prompt them for a confirm/deny response to the message. Arguments: msg (string): The message to display to the user Returns: True if the user picks 'Confirm', False if the user picks 'Deny' Raises: KeyError: If the options passed to the prompt handler doesn't contain a `msg` attribute. APITimeoutError: If the timeout value is reached without receiving a response.
[ "Send", "a", "user", "prompt", "request", "to", "the", "GUI" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/api.py#L591-L636
train
42,801
NASA-AMMOS/AIT-Core
ait/core/server/broker.py
Broker._subscribe_all
def _subscribe_all(self): """ Subscribes all streams to their input. Subscribes all plugins to all their inputs. Subscribes all plugin outputs to the plugin. """ for stream in (self.inbound_streams + self.outbound_streams): for input_ in stream.inputs: if not type(input_) is int and input_ is not None: self._subscribe(stream, input_) for plugin in self.plugins: for input_ in plugin.inputs: self._subscribe(plugin, input_) for output in plugin.outputs: # Find output stream instance subscriber = next((x for x in self.outbound_streams if x.name == output), None) if subscriber is None: log.warn('The outbound stream {} does not ' 'exist so will not receive messages ' 'from {}'.format(output, plugin)) else: self._subscribe(subscriber, plugin.name)
python
def _subscribe_all(self): """ Subscribes all streams to their input. Subscribes all plugins to all their inputs. Subscribes all plugin outputs to the plugin. """ for stream in (self.inbound_streams + self.outbound_streams): for input_ in stream.inputs: if not type(input_) is int and input_ is not None: self._subscribe(stream, input_) for plugin in self.plugins: for input_ in plugin.inputs: self._subscribe(plugin, input_) for output in plugin.outputs: # Find output stream instance subscriber = next((x for x in self.outbound_streams if x.name == output), None) if subscriber is None: log.warn('The outbound stream {} does not ' 'exist so will not receive messages ' 'from {}'.format(output, plugin)) else: self._subscribe(subscriber, plugin.name)
[ "def", "_subscribe_all", "(", "self", ")", ":", "for", "stream", "in", "(", "self", ".", "inbound_streams", "+", "self", ".", "outbound_streams", ")", ":", "for", "input_", "in", "stream", ".", "inputs", ":", "if", "not", "type", "(", "input_", ")", "i...
Subscribes all streams to their input. Subscribes all plugins to all their inputs. Subscribes all plugin outputs to the plugin.
[ "Subscribes", "all", "streams", "to", "their", "input", ".", "Subscribes", "all", "plugins", "to", "all", "their", "inputs", ".", "Subscribes", "all", "plugin", "outputs", "to", "the", "plugin", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/broker.py#L58-L82
train
42,802
NASA-AMMOS/AIT-Core
ait/core/log.py
SysLogFormatter.format
def format (self, record): """Returns the given LogRecord as formatted text.""" record.hostname = self.hostname return logging.Formatter.format(self, record)
python
def format (self, record): """Returns the given LogRecord as formatted text.""" record.hostname = self.hostname return logging.Formatter.format(self, record)
[ "def", "format", "(", "self", ",", "record", ")", ":", "record", ".", "hostname", "=", "self", ".", "hostname", "return", "logging", ".", "Formatter", ".", "format", "(", "self", ",", "record", ")" ]
Returns the given LogRecord as formatted text.
[ "Returns", "the", "given", "LogRecord", "as", "formatted", "text", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L117-L120
train
42,803
NASA-AMMOS/AIT-Core
ait/core/log.py
SysLogFormatter.formatTime
def formatTime (self, record, datefmt=None): """Returns the creation time of the given LogRecord as formatted text. NOTE: The datefmt parameter and self.converter (the time conversion method) are ignored. BSD Syslog Protocol messages always use local time, and by our convention, Syslog Protocol messages use UTC. """ if self.bsd: lt_ts = datetime.datetime.fromtimestamp(record.created) ts = lt_ts.strftime(self.BSD_DATEFMT) if ts[4] == '0': ts = ts[0:4] + ' ' + ts[5:] else: utc_ts = datetime.datetime.utcfromtimestamp(record.created) ts = utc_ts.strftime(self.SYS_DATEFMT) return ts
python
def formatTime (self, record, datefmt=None): """Returns the creation time of the given LogRecord as formatted text. NOTE: The datefmt parameter and self.converter (the time conversion method) are ignored. BSD Syslog Protocol messages always use local time, and by our convention, Syslog Protocol messages use UTC. """ if self.bsd: lt_ts = datetime.datetime.fromtimestamp(record.created) ts = lt_ts.strftime(self.BSD_DATEFMT) if ts[4] == '0': ts = ts[0:4] + ' ' + ts[5:] else: utc_ts = datetime.datetime.utcfromtimestamp(record.created) ts = utc_ts.strftime(self.SYS_DATEFMT) return ts
[ "def", "formatTime", "(", "self", ",", "record", ",", "datefmt", "=", "None", ")", ":", "if", "self", ".", "bsd", ":", "lt_ts", "=", "datetime", ".", "datetime", ".", "fromtimestamp", "(", "record", ".", "created", ")", "ts", "=", "lt_ts", ".", "strf...
Returns the creation time of the given LogRecord as formatted text. NOTE: The datefmt parameter and self.converter (the time conversion method) are ignored. BSD Syslog Protocol messages always use local time, and by our convention, Syslog Protocol messages use UTC.
[ "Returns", "the", "creation", "time", "of", "the", "given", "LogRecord", "as", "formatted", "text", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/log.py#L123-L139
train
42,804
NASA-AMMOS/AIT-Core
ait/core/pcap.py
query
def query(starttime, endtime, output=None, *filenames): '''Given a time range and input file, query creates a new file with only that subset of data. If no outfile name is given, the new file name is the old file name with the time range appended. Args: starttime: The datetime of the beginning time range to be extracted from the files. endtime: The datetime of the end of the time range to be extracted from the files. output: Optional: The output file name. Defaults to [first filename in filenames][starttime]-[endtime].pcap filenames: A tuple of one or more file names to extract data from. ''' if not output: output = (filenames[0].replace('.pcap','') + starttime.isoformat() + '-' + endtime.isoformat() + '.pcap') else: output = output with open(output,'w') as outfile: for filename in filenames: log.info("pcap.query: processing %s..." % filename) with open(filename, 'r') as stream: for header, packet in stream: if packet is not None: if header.timestamp >= starttime and header.timestamp <= endtime: outfile.write(packet, header=header)
python
def query(starttime, endtime, output=None, *filenames): '''Given a time range and input file, query creates a new file with only that subset of data. If no outfile name is given, the new file name is the old file name with the time range appended. Args: starttime: The datetime of the beginning time range to be extracted from the files. endtime: The datetime of the end of the time range to be extracted from the files. output: Optional: The output file name. Defaults to [first filename in filenames][starttime]-[endtime].pcap filenames: A tuple of one or more file names to extract data from. ''' if not output: output = (filenames[0].replace('.pcap','') + starttime.isoformat() + '-' + endtime.isoformat() + '.pcap') else: output = output with open(output,'w') as outfile: for filename in filenames: log.info("pcap.query: processing %s..." % filename) with open(filename, 'r') as stream: for header, packet in stream: if packet is not None: if header.timestamp >= starttime and header.timestamp <= endtime: outfile.write(packet, header=header)
[ "def", "query", "(", "starttime", ",", "endtime", ",", "output", "=", "None", ",", "*", "filenames", ")", ":", "if", "not", "output", ":", "output", "=", "(", "filenames", "[", "0", "]", ".", "replace", "(", "'.pcap'", ",", "''", ")", "+", "startti...
Given a time range and input file, query creates a new file with only that subset of data. If no outfile name is given, the new file name is the old file name with the time range appended. Args: starttime: The datetime of the beginning time range to be extracted from the files. endtime: The datetime of the end of the time range to be extracted from the files. output: Optional: The output file name. Defaults to [first filename in filenames][starttime]-[endtime].pcap filenames: A tuple of one or more file names to extract data from.
[ "Given", "a", "time", "range", "and", "input", "file", "query", "creates", "a", "new", "file", "with", "only", "that", "subset", "of", "data", ".", "If", "no", "outfile", "name", "is", "given", "the", "new", "file", "name", "is", "the", "old", "file", ...
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L467-L496
train
42,805
NASA-AMMOS/AIT-Core
ait/core/pcap.py
PCapGlobalHeader.read
def read (self, stream): """Reads PCapGlobalHeader data from the given stream.""" self._data = stream.read(self._size) if len(self._data) >= self._size: values = struct.unpack(self._format, self._data) else: values = None, None, None, None, None, None, None if values[0] == 0xA1B2C3D4 or values[0] == 0xA1B23C4D: self._swap = '@' elif values[0] == 0xD4C3B2A1 or values[0] == 0x4D3CB2A1: self._swap = EndianSwap if values[0] is not None: values = struct.unpack(self._swap + self._format, self._data) self.magic_number = values[0] self.version_major = values[1] self.version_minor = values[2] self.thiszone = values[3] self.sigfigs = values[4] self.snaplen = values[5] self.network = values[6]
python
def read (self, stream): """Reads PCapGlobalHeader data from the given stream.""" self._data = stream.read(self._size) if len(self._data) >= self._size: values = struct.unpack(self._format, self._data) else: values = None, None, None, None, None, None, None if values[0] == 0xA1B2C3D4 or values[0] == 0xA1B23C4D: self._swap = '@' elif values[0] == 0xD4C3B2A1 or values[0] == 0x4D3CB2A1: self._swap = EndianSwap if values[0] is not None: values = struct.unpack(self._swap + self._format, self._data) self.magic_number = values[0] self.version_major = values[1] self.version_minor = values[2] self.thiszone = values[3] self.sigfigs = values[4] self.snaplen = values[5] self.network = values[6]
[ "def", "read", "(", "self", ",", "stream", ")", ":", "self", ".", "_data", "=", "stream", ".", "read", "(", "self", ".", "_size", ")", "if", "len", "(", "self", ".", "_data", ")", ">=", "self", ".", "_size", ":", "values", "=", "struct", ".", "...
Reads PCapGlobalHeader data from the given stream.
[ "Reads", "PCapGlobalHeader", "data", "from", "the", "given", "stream", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L100-L123
train
42,806
NASA-AMMOS/AIT-Core
ait/core/pcap.py
PCapPacketHeader.read
def read (self, stream): """Reads PCapPacketHeader data from the given stream.""" self._data = stream.read(self._size) if len(self._data) >= self._size: values = struct.unpack(self._swap + self._format, self._data) else: values = None, None, None, None self.ts_sec = values[0] self.ts_usec = values[1] self.incl_len = values[2] self.orig_len = values[3]
python
def read (self, stream): """Reads PCapPacketHeader data from the given stream.""" self._data = stream.read(self._size) if len(self._data) >= self._size: values = struct.unpack(self._swap + self._format, self._data) else: values = None, None, None, None self.ts_sec = values[0] self.ts_usec = values[1] self.incl_len = values[2] self.orig_len = values[3]
[ "def", "read", "(", "self", ",", "stream", ")", ":", "self", ".", "_data", "=", "stream", ".", "read", "(", "self", ".", "_size", ")", "if", "len", "(", "self", ".", "_data", ")", ">=", "self", ".", "_size", ":", "values", "=", "struct", ".", "...
Reads PCapPacketHeader data from the given stream.
[ "Reads", "PCapPacketHeader", "data", "from", "the", "given", "stream", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L186-L198
train
42,807
NASA-AMMOS/AIT-Core
ait/core/pcap.py
PCapRolloverStream.rollover
def rollover (self): """Indicates whether or not its time to rollover to a new file.""" rollover = False if not rollover and self._threshold.nbytes is not None: rollover = self._total.nbytes >= self._threshold.nbytes if not rollover and self._threshold.npackets is not None: rollover = self._total.npackets >= self._threshold.npackets if not rollover and self._threshold.nseconds is not None: nseconds = math.ceil(self._total.nseconds) rollover = nseconds >= self._threshold.nseconds return rollover
python
def rollover (self): """Indicates whether or not its time to rollover to a new file.""" rollover = False if not rollover and self._threshold.nbytes is not None: rollover = self._total.nbytes >= self._threshold.nbytes if not rollover and self._threshold.npackets is not None: rollover = self._total.npackets >= self._threshold.npackets if not rollover and self._threshold.nseconds is not None: nseconds = math.ceil(self._total.nseconds) rollover = nseconds >= self._threshold.nseconds return rollover
[ "def", "rollover", "(", "self", ")", ":", "rollover", "=", "False", "if", "not", "rollover", "and", "self", ".", "_threshold", ".", "nbytes", "is", "not", "None", ":", "rollover", "=", "self", ".", "_total", ".", "nbytes", ">=", "self", ".", "_threshol...
Indicates whether or not its time to rollover to a new file.
[ "Indicates", "whether", "or", "not", "its", "time", "to", "rollover", "to", "a", "new", "file", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L255-L269
train
42,808
NASA-AMMOS/AIT-Core
ait/core/pcap.py
PCapRolloverStream.write
def write (self, bytes, header=None): """Writes packet ``bytes`` and the optional pcap packet ``header``. If the pcap packet ``header`` is not specified, one will be generated based on the number of packet ``bytes`` and current time. """ if header is None: header = PCapPacketHeader(orig_len=len(bytes)) if self._stream is None: if self._threshold.nseconds is not None: # Round down to the nearest multiple of nseconds nseconds = self._threshold.nseconds remainder = int( math.floor( header.ts % nseconds ) ) delta = datetime.timedelta(seconds=remainder) timestamp = header.timestamp - delta else: timestamp = header.timestamp self._filename = timestamp.strftime(self._format) self._startTime = calendar.timegm( timestamp.replace(microsecond=0).timetuple() ) if self._dryrun: self._stream = True self._total.nbytes += len(PCapGlobalHeader()) else: self._stream = open(self._filename, 'w') self._total.nbytes += len(self._stream.header) if not self._dryrun: self._stream.write(bytes, header) self._total.nbytes += len(bytes) + len(header) self._total.npackets += 1 self._total.nseconds = header.ts - self._startTime if self.rollover: self.close() return header.incl_len
python
def write (self, bytes, header=None): """Writes packet ``bytes`` and the optional pcap packet ``header``. If the pcap packet ``header`` is not specified, one will be generated based on the number of packet ``bytes`` and current time. """ if header is None: header = PCapPacketHeader(orig_len=len(bytes)) if self._stream is None: if self._threshold.nseconds is not None: # Round down to the nearest multiple of nseconds nseconds = self._threshold.nseconds remainder = int( math.floor( header.ts % nseconds ) ) delta = datetime.timedelta(seconds=remainder) timestamp = header.timestamp - delta else: timestamp = header.timestamp self._filename = timestamp.strftime(self._format) self._startTime = calendar.timegm( timestamp.replace(microsecond=0).timetuple() ) if self._dryrun: self._stream = True self._total.nbytes += len(PCapGlobalHeader()) else: self._stream = open(self._filename, 'w') self._total.nbytes += len(self._stream.header) if not self._dryrun: self._stream.write(bytes, header) self._total.nbytes += len(bytes) + len(header) self._total.npackets += 1 self._total.nseconds = header.ts - self._startTime if self.rollover: self.close() return header.incl_len
[ "def", "write", "(", "self", ",", "bytes", ",", "header", "=", "None", ")", ":", "if", "header", "is", "None", ":", "header", "=", "PCapPacketHeader", "(", "orig_len", "=", "len", "(", "bytes", ")", ")", "if", "self", ".", "_stream", "is", "None", ...
Writes packet ``bytes`` and the optional pcap packet ``header``. If the pcap packet ``header`` is not specified, one will be generated based on the number of packet ``bytes`` and current time.
[ "Writes", "packet", "bytes", "and", "the", "optional", "pcap", "packet", "header", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/pcap.py#L272-L313
train
42,809
NASA-AMMOS/AIT-Core
ait/core/table.py
hash_file
def hash_file(filename): """"This function returns the SHA-1 hash of the file passed into it""" # make a hash object h = hashlib.sha1() # open file for reading in binary mode with open(filename,'rb') as file: # loop till the end of the file chunk = 0 while chunk != b'': # read only 1024 bytes at a time chunk = file.read(1024) h.update(chunk) # return the hex representation of digest return h.hexdigest()
python
def hash_file(filename): """"This function returns the SHA-1 hash of the file passed into it""" # make a hash object h = hashlib.sha1() # open file for reading in binary mode with open(filename,'rb') as file: # loop till the end of the file chunk = 0 while chunk != b'': # read only 1024 bytes at a time chunk = file.read(1024) h.update(chunk) # return the hex representation of digest return h.hexdigest()
[ "def", "hash_file", "(", "filename", ")", ":", "# make a hash object", "h", "=", "hashlib", ".", "sha1", "(", ")", "# open file for reading in binary mode", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "file", ":", "# loop till the end of the file", "c...
This function returns the SHA-1 hash of the file passed into it
[ "This", "function", "returns", "the", "SHA", "-", "1", "hash", "of", "the", "file", "passed", "into", "it" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L156-L174
train
42,810
NASA-AMMOS/AIT-Core
ait/core/table.py
FSWTabDict.create
def create (self, name, *args): """Creates a new command with the given arguments.""" tab = None defn = self.get(name, None) if defn: tab = FSWTab(defn, *args) return tab
python
def create (self, name, *args): """Creates a new command with the given arguments.""" tab = None defn = self.get(name, None) if defn: tab = FSWTab(defn, *args) return tab
[ "def", "create", "(", "self", ",", "name", ",", "*", "args", ")", ":", "tab", "=", "None", "defn", "=", "self", ".", "get", "(", "name", ",", "None", ")", "if", "defn", ":", "tab", "=", "FSWTab", "(", "defn", ",", "*", "args", ")", "return", ...
Creates a new command with the given arguments.
[ "Creates", "a", "new", "command", "with", "the", "given", "arguments", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L598-L604
train
42,811
NASA-AMMOS/AIT-Core
ait/core/table.py
FSWTabDict.load
def load (self, filename): """Loads Command Definitions from the given YAML file into this Command Dictionary. """ if self.filename is None: self.filename = filename stream = open(self.filename, "rb") for doc in yaml.load_all(stream): for table in doc: self.add(table) stream.close()
python
def load (self, filename): """Loads Command Definitions from the given YAML file into this Command Dictionary. """ if self.filename is None: self.filename = filename stream = open(self.filename, "rb") for doc in yaml.load_all(stream): for table in doc: self.add(table) stream.close()
[ "def", "load", "(", "self", ",", "filename", ")", ":", "if", "self", ".", "filename", "is", "None", ":", "self", ".", "filename", "=", "filename", "stream", "=", "open", "(", "self", ".", "filename", ",", "\"rb\"", ")", "for", "doc", "in", "yaml", ...
Loads Command Definitions from the given YAML file into this Command Dictionary.
[ "Loads", "Command", "Definitions", "from", "the", "given", "YAML", "file", "into", "this", "Command", "Dictionary", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/table.py#L606-L617
train
42,812
NASA-AMMOS/AIT-Core
ait/core/server/client.py
ZMQClient.publish
def publish(self, msg): """ Publishes input message with client name as topic. """ self.pub.send("{} {}".format(self.name, msg)) log.debug('Published message from {}'.format(self))
python
def publish(self, msg): """ Publishes input message with client name as topic. """ self.pub.send("{} {}".format(self.name, msg)) log.debug('Published message from {}'.format(self))
[ "def", "publish", "(", "self", ",", "msg", ")", ":", "self", ".", "pub", ".", "send", "(", "\"{} {}\"", ".", "format", "(", "self", ".", "name", ",", "msg", ")", ")", "log", ".", "debug", "(", "'Published message from {}'", ".", "format", "(", "self"...
Publishes input message with client name as topic.
[ "Publishes", "input", "message", "with", "client", "name", "as", "topic", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/server/client.py#L34-L39
train
42,813
NASA-AMMOS/AIT-Core
ait/core/db.py
create
def create(database, tlmdict=None): """Creates a new database for the given Telemetry Dictionary and returns a connection to it. """ if tlmdict is None: tlmdict = tlm.getDefaultDict() dbconn = connect(database) for name, defn in tlmdict.items(): createTable(dbconn, defn) return dbconn
python
def create(database, tlmdict=None): """Creates a new database for the given Telemetry Dictionary and returns a connection to it. """ if tlmdict is None: tlmdict = tlm.getDefaultDict() dbconn = connect(database) for name, defn in tlmdict.items(): createTable(dbconn, defn) return dbconn
[ "def", "create", "(", "database", ",", "tlmdict", "=", "None", ")", ":", "if", "tlmdict", "is", "None", ":", "tlmdict", "=", "tlm", ".", "getDefaultDict", "(", ")", "dbconn", "=", "connect", "(", "database", ")", "for", "name", ",", "defn", "in", "tl...
Creates a new database for the given Telemetry Dictionary and returns a connection to it.
[ "Creates", "a", "new", "database", "for", "the", "given", "Telemetry", "Dictionary", "and", "returns", "a", "connection", "to", "it", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L45-L57
train
42,814
NASA-AMMOS/AIT-Core
ait/core/db.py
createTable
def createTable(dbconn, pd): """Creates a database table for the given PacketDefinition.""" cols = ('%s %s' % (defn.name, getTypename(defn)) for defn in pd.fields) sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (pd.name, ', '.join(cols)) dbconn.execute(sql) dbconn.commit()
python
def createTable(dbconn, pd): """Creates a database table for the given PacketDefinition.""" cols = ('%s %s' % (defn.name, getTypename(defn)) for defn in pd.fields) sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (pd.name, ', '.join(cols)) dbconn.execute(sql) dbconn.commit()
[ "def", "createTable", "(", "dbconn", ",", "pd", ")", ":", "cols", "=", "(", "'%s %s'", "%", "(", "defn", ".", "name", ",", "getTypename", "(", "defn", ")", ")", "for", "defn", "in", "pd", ".", "fields", ")", "sql", "=", "'CREATE TABLE IF NOT EXISTS %s ...
Creates a database table for the given PacketDefinition.
[ "Creates", "a", "database", "table", "for", "the", "given", "PacketDefinition", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L61-L67
train
42,815
NASA-AMMOS/AIT-Core
ait/core/db.py
insert
def insert(dbconn, packet): """Inserts the given packet into the connected database.""" values = [ ] pd = packet._defn for defn in pd.fields: if defn.enum: val = getattr(packet.raw, defn.name) else: val = getattr(packet, defn.name) if val is None and defn.name in pd.history: val = getattr(packet.history, defn.name) values.append(val) qmark = ['?'] * len(values) sql = 'INSERT INTO %s VALUES (%s)' % (pd.name, ', '.join(qmark)) dbconn.execute(sql, values)
python
def insert(dbconn, packet): """Inserts the given packet into the connected database.""" values = [ ] pd = packet._defn for defn in pd.fields: if defn.enum: val = getattr(packet.raw, defn.name) else: val = getattr(packet, defn.name) if val is None and defn.name in pd.history: val = getattr(packet.history, defn.name) values.append(val) qmark = ['?'] * len(values) sql = 'INSERT INTO %s VALUES (%s)' % (pd.name, ', '.join(qmark)) dbconn.execute(sql, values)
[ "def", "insert", "(", "dbconn", ",", "packet", ")", ":", "values", "=", "[", "]", "pd", "=", "packet", ".", "_defn", "for", "defn", "in", "pd", ".", "fields", ":", "if", "defn", ".", "enum", ":", "val", "=", "getattr", "(", "packet", ".", "raw", ...
Inserts the given packet into the connected database.
[ "Inserts", "the", "given", "packet", "into", "the", "connected", "database", "." ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L78-L97
train
42,816
NASA-AMMOS/AIT-Core
ait/core/db.py
InfluxDBBackend.connect
def connect(self, **kwargs): ''' Connect to an InfluxDB instance Connects to an InfluxDB instance and switches to a given database. If the database doesn't exist it is created first via :func:`create`. **Configuration Parameters** host The host for the connection. Passed as either the config key **database.host** or the kwargs argument **host**. Defaults to **localhost**. port The port for the connection. Passed as either the config key **database.port** or the kwargs argument **port**. Defaults to **8086**. un The un for the connection. Passed as either the config key **database.un** or the kwargs argument **un**. Defaults to **root**. pw The pw for the connection. Passed as either the config key **database.pw** or the kwargs argument **pw**. Defaults to **pw**. database name The database name for the connection. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**. ''' host = ait.config.get('database.host', kwargs.get('host', 'localhost')) port = ait.config.get('database.port', kwargs.get('port', 8086)) un = ait.config.get('database.un', kwargs.get('un', 'root')) pw = ait.config.get('database.pw', kwargs.get('pw', 'root')) dbname = ait.config.get('database.dbname', kwargs.get('database', 'ait')) self._conn = self._backend.InfluxDBClient(host, port, un, pw) if dbname not in [v['name'] for v in self._conn.get_list_database()]: self.create(database=dbname) self._conn.switch_database(dbname)
python
def connect(self, **kwargs): ''' Connect to an InfluxDB instance Connects to an InfluxDB instance and switches to a given database. If the database doesn't exist it is created first via :func:`create`. **Configuration Parameters** host The host for the connection. Passed as either the config key **database.host** or the kwargs argument **host**. Defaults to **localhost**. port The port for the connection. Passed as either the config key **database.port** or the kwargs argument **port**. Defaults to **8086**. un The un for the connection. Passed as either the config key **database.un** or the kwargs argument **un**. Defaults to **root**. pw The pw for the connection. Passed as either the config key **database.pw** or the kwargs argument **pw**. Defaults to **pw**. database name The database name for the connection. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**. ''' host = ait.config.get('database.host', kwargs.get('host', 'localhost')) port = ait.config.get('database.port', kwargs.get('port', 8086)) un = ait.config.get('database.un', kwargs.get('un', 'root')) pw = ait.config.get('database.pw', kwargs.get('pw', 'root')) dbname = ait.config.get('database.dbname', kwargs.get('database', 'ait')) self._conn = self._backend.InfluxDBClient(host, port, un, pw) if dbname not in [v['name'] for v in self._conn.get_list_database()]: self.create(database=dbname) self._conn.switch_database(dbname)
[ "def", "connect", "(", "self", ",", "*", "*", "kwargs", ")", ":", "host", "=", "ait", ".", "config", ".", "get", "(", "'database.host'", ",", "kwargs", ".", "get", "(", "'host'", ",", "'localhost'", ")", ")", "port", "=", "ait", ".", "config", ".",...
Connect to an InfluxDB instance Connects to an InfluxDB instance and switches to a given database. If the database doesn't exist it is created first via :func:`create`. **Configuration Parameters** host The host for the connection. Passed as either the config key **database.host** or the kwargs argument **host**. Defaults to **localhost**. port The port for the connection. Passed as either the config key **database.port** or the kwargs argument **port**. Defaults to **8086**. un The un for the connection. Passed as either the config key **database.un** or the kwargs argument **un**. Defaults to **root**. pw The pw for the connection. Passed as either the config key **database.pw** or the kwargs argument **pw**. Defaults to **pw**. database name The database name for the connection. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**.
[ "Connect", "to", "an", "InfluxDB", "instance" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L221-L265
train
42,817
NASA-AMMOS/AIT-Core
ait/core/db.py
InfluxDBBackend.create
def create(self, **kwargs): ''' Create a database in a connected InfluxDB instance **Configuration Parameters** database name The database name to create. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**. Raises: AttributeError: If a connection to the database doesn't exist ''' dbname = ait.config.get('database.dbname', kwargs.get('database', 'ait')) if self._conn is None: raise AttributeError('Unable to create database. No connection to database exists.') self._conn.create_database(dbname) self._conn.switch_database(dbname)
python
def create(self, **kwargs): ''' Create a database in a connected InfluxDB instance **Configuration Parameters** database name The database name to create. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**. Raises: AttributeError: If a connection to the database doesn't exist ''' dbname = ait.config.get('database.dbname', kwargs.get('database', 'ait')) if self._conn is None: raise AttributeError('Unable to create database. No connection to database exists.') self._conn.create_database(dbname) self._conn.switch_database(dbname)
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "dbname", "=", "ait", ".", "config", ".", "get", "(", "'database.dbname'", ",", "kwargs", ".", "get", "(", "'database'", ",", "'ait'", ")", ")", "if", "self", ".", "_conn", "is", "Non...
Create a database in a connected InfluxDB instance **Configuration Parameters** database name The database name to create. Passed as either the config key **database.dbname** or the kwargs argument **database**. Defaults to **ait**. Raises: AttributeError: If a connection to the database doesn't exist
[ "Create", "a", "database", "in", "a", "connected", "InfluxDB", "instance" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L267-L287
train
42,818
NASA-AMMOS/AIT-Core
ait/core/db.py
InfluxDBBackend.create_packets_from_results
def create_packets_from_results(self, packet_name, result_set): ''' Generate AIT Packets from a InfluxDB query ResultSet Extract Influx DB query results into one packet per result entry. This assumes that telemetry data was inserted in the format generated by :func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are evaluated if they can be properly encoded from the raw value in the query result. If there is no opcode / EVR-code for a particular raw value the value is skipped (and thus defaulted to 0). Arguments packet_name (string) The name of the AIT Packet to create from each result entry result_set (influxdb.resultset.ResultSet) The query ResultSet object to convert into packets Returns A list of packets extracted from the ResultSet object or None if an invalid packet name is supplied. ''' try: pkt_defn = tlm.getDefaultDict()[packet_name] except KeyError: log.error('Unknown packet name {} Unable to unpack ResultSet'.format(packet_name)) return None pkt = tlm.Packet(pkt_defn) pkts = [] for r in result_set.get_points(): new_pkt = tlm.Packet(pkt_defn) for f, f_defn in pkt_defn.fieldmap.iteritems(): field_type_name = f_defn.type.name if field_type_name == 'CMD16': if cmd.getDefaultDict().opcodes.get(r[f], None): setattr(new_pkt, f, cmd_def.name) elif field_type_name == 'EVR16': if evr.getDefaultDict().codes.get(r[f], None): setattr(new_pkt, f, r[f]) elif field_type_name == 'TIME8': setattr(new_pkt, f, r[f] / 256.0) elif field_type_name == 'TIME32': new_val = dmc.GPS_Epoch + dt.timedelta(seconds=r[f]) setattr(new_pkt, f, new_val) elif field_type_name == 'TIME40': sec = int(r[f]) microsec = r[f] * 1e6 new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec) setattr(new_pkt, f, new_val) elif field_type_name == 'TIME64': sec = int(r[f]) microsec = r[f] % 1 * 1e6 new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec) setattr(new_pkt, f, new_val) else: try: setattr(new_pkt, f, r[f]) except KeyError: log.info('Field not found in query results {} Skipping ...'.format(f)) pkts.append(new_pkt) return pkts
python
def create_packets_from_results(self, packet_name, result_set): ''' Generate AIT Packets from a InfluxDB query ResultSet Extract Influx DB query results into one packet per result entry. This assumes that telemetry data was inserted in the format generated by :func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are evaluated if they can be properly encoded from the raw value in the query result. If there is no opcode / EVR-code for a particular raw value the value is skipped (and thus defaulted to 0). Arguments packet_name (string) The name of the AIT Packet to create from each result entry result_set (influxdb.resultset.ResultSet) The query ResultSet object to convert into packets Returns A list of packets extracted from the ResultSet object or None if an invalid packet name is supplied. ''' try: pkt_defn = tlm.getDefaultDict()[packet_name] except KeyError: log.error('Unknown packet name {} Unable to unpack ResultSet'.format(packet_name)) return None pkt = tlm.Packet(pkt_defn) pkts = [] for r in result_set.get_points(): new_pkt = tlm.Packet(pkt_defn) for f, f_defn in pkt_defn.fieldmap.iteritems(): field_type_name = f_defn.type.name if field_type_name == 'CMD16': if cmd.getDefaultDict().opcodes.get(r[f], None): setattr(new_pkt, f, cmd_def.name) elif field_type_name == 'EVR16': if evr.getDefaultDict().codes.get(r[f], None): setattr(new_pkt, f, r[f]) elif field_type_name == 'TIME8': setattr(new_pkt, f, r[f] / 256.0) elif field_type_name == 'TIME32': new_val = dmc.GPS_Epoch + dt.timedelta(seconds=r[f]) setattr(new_pkt, f, new_val) elif field_type_name == 'TIME40': sec = int(r[f]) microsec = r[f] * 1e6 new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec) setattr(new_pkt, f, new_val) elif field_type_name == 'TIME64': sec = int(r[f]) microsec = r[f] % 1 * 1e6 new_val = dmc.GPS_Epoch + dt.timedelta(seconds=sec, microseconds=microsec) setattr(new_pkt, f, new_val) else: try: setattr(new_pkt, f, r[f]) except KeyError: log.info('Field not found in query results {} Skipping ...'.format(f)) pkts.append(new_pkt) return pkts
[ "def", "create_packets_from_results", "(", "self", ",", "packet_name", ",", "result_set", ")", ":", "try", ":", "pkt_defn", "=", "tlm", ".", "getDefaultDict", "(", ")", "[", "packet_name", "]", "except", "KeyError", ":", "log", ".", "error", "(", "'Unknown p...
Generate AIT Packets from a InfluxDB query ResultSet Extract Influx DB query results into one packet per result entry. This assumes that telemetry data was inserted in the format generated by :func:`InfluxDBBackend.insert`. Complex types such as CMD16 and EVR16 are evaluated if they can be properly encoded from the raw value in the query result. If there is no opcode / EVR-code for a particular raw value the value is skipped (and thus defaulted to 0). Arguments packet_name (string) The name of the AIT Packet to create from each result entry result_set (influxdb.resultset.ResultSet) The query ResultSet object to convert into packets Returns A list of packets extracted from the ResultSet object or None if an invalid packet name is supplied.
[ "Generate", "AIT", "Packets", "from", "a", "InfluxDB", "query", "ResultSet" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L359-L423
train
42,819
NASA-AMMOS/AIT-Core
ait/core/db.py
SQLiteBackend.create
def create(self, **kwargs): ''' Create a database for the current telemetry dictionary Connects to a SQLite instance via :func:`connect` and creates a skeleton database for future data inserts. **Configuration Parameters** tlmdict The :class:`ait.core.tlm.TlmDict` instance to use. Defaults to the currently configured telemetry dictionary. ''' tlmdict = kwargs.get('tlmdict', tlm.getDefaultDict()) self.connect(**kwargs) for name, defn in tlmdict.items(): self._create_table(defn)
python
def create(self, **kwargs): ''' Create a database for the current telemetry dictionary Connects to a SQLite instance via :func:`connect` and creates a skeleton database for future data inserts. **Configuration Parameters** tlmdict The :class:`ait.core.tlm.TlmDict` instance to use. Defaults to the currently configured telemetry dictionary. ''' tlmdict = kwargs.get('tlmdict', tlm.getDefaultDict()) self.connect(**kwargs) for name, defn in tlmdict.items(): self._create_table(defn)
[ "def", "create", "(", "self", ",", "*", "*", "kwargs", ")", ":", "tlmdict", "=", "kwargs", ".", "get", "(", "'tlmdict'", ",", "tlm", ".", "getDefaultDict", "(", ")", ")", "self", ".", "connect", "(", "*", "*", "kwargs", ")", "for", "name", ",", "...
Create a database for the current telemetry dictionary Connects to a SQLite instance via :func:`connect` and creates a skeleton database for future data inserts. **Configuration Parameters** tlmdict The :class:`ait.core.tlm.TlmDict` instance to use. Defaults to the currently configured telemetry dictionary.
[ "Create", "a", "database", "for", "the", "current", "telemetry", "dictionary" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L447-L465
train
42,820
NASA-AMMOS/AIT-Core
ait/core/db.py
SQLiteBackend._create_table
def _create_table(self, packet_defn): ''' Creates a database table for the given PacketDefinition Arguments packet_defn The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry should be made. ''' cols = ('%s %s' % (defn.name, self._getTypename(defn)) for defn in packet_defn.fields) sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (packet_defn.name, ', '.join(cols)) self._conn.execute(sql) self._conn.commit()
python
def _create_table(self, packet_defn): ''' Creates a database table for the given PacketDefinition Arguments packet_defn The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry should be made. ''' cols = ('%s %s' % (defn.name, self._getTypename(defn)) for defn in packet_defn.fields) sql = 'CREATE TABLE IF NOT EXISTS %s (%s)' % (packet_defn.name, ', '.join(cols)) self._conn.execute(sql) self._conn.commit()
[ "def", "_create_table", "(", "self", ",", "packet_defn", ")", ":", "cols", "=", "(", "'%s %s'", "%", "(", "defn", ".", "name", ",", "self", ".", "_getTypename", "(", "defn", ")", ")", "for", "defn", "in", "packet_defn", ".", "fields", ")", "sql", "="...
Creates a database table for the given PacketDefinition Arguments packet_defn The :class:`ait.core.tlm.PacketDefinition` instance for which a table entry should be made.
[ "Creates", "a", "database", "table", "for", "the", "given", "PacketDefinition" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L467-L479
train
42,821
NASA-AMMOS/AIT-Core
ait/core/db.py
SQLiteBackend._getTypename
def _getTypename(self, defn): """ Returns the SQL typename required to store the given FieldDefinition """ return 'REAL' if defn.type.float or 'TIME' in defn.type.name or defn.dntoeu else 'INTEGER'
python
def _getTypename(self, defn): """ Returns the SQL typename required to store the given FieldDefinition """ return 'REAL' if defn.type.float or 'TIME' in defn.type.name or defn.dntoeu else 'INTEGER'
[ "def", "_getTypename", "(", "self", ",", "defn", ")", ":", "return", "'REAL'", "if", "defn", ".", "type", ".", "float", "or", "'TIME'", "in", "defn", ".", "type", ".", "name", "or", "defn", ".", "dntoeu", "else", "'INTEGER'" ]
Returns the SQL typename required to store the given FieldDefinition
[ "Returns", "the", "SQL", "typename", "required", "to", "store", "the", "given", "FieldDefinition" ]
9d85bd9c738e7a6a6fbdff672bea708238b02a3a
https://github.com/NASA-AMMOS/AIT-Core/blob/9d85bd9c738e7a6a6fbdff672bea708238b02a3a/ait/core/db.py#L523-L525
train
42,822
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/cube/bloom.py
genCubeVector
def genCubeVector(x, y, z, x_mult=1, y_mult=1, z_mult=1): """Generates a map of vector lengths from the center point to each coordinate x - width of matrix to generate y - height of matrix to generate z - depth of matrix to generate x_mult - value to scale x-axis by y_mult - value to scale y-axis by z_mult - value to scale z-axis by """ cX = (x - 1) / 2.0 cY = (y - 1) / 2.0 cZ = (z - 1) / 2.0 def vect(_x, _y, _z): return int(math.sqrt(math.pow(_x - cX, 2 * x_mult) + math.pow(_y - cY, 2 * y_mult) + math.pow(_z - cZ, 2 * z_mult))) return [[[vect(_x, _y, _z) for _z in range(z)] for _y in range(y)] for _x in range(x)]
python
def genCubeVector(x, y, z, x_mult=1, y_mult=1, z_mult=1): """Generates a map of vector lengths from the center point to each coordinate x - width of matrix to generate y - height of matrix to generate z - depth of matrix to generate x_mult - value to scale x-axis by y_mult - value to scale y-axis by z_mult - value to scale z-axis by """ cX = (x - 1) / 2.0 cY = (y - 1) / 2.0 cZ = (z - 1) / 2.0 def vect(_x, _y, _z): return int(math.sqrt(math.pow(_x - cX, 2 * x_mult) + math.pow(_y - cY, 2 * y_mult) + math.pow(_z - cZ, 2 * z_mult))) return [[[vect(_x, _y, _z) for _z in range(z)] for _y in range(y)] for _x in range(x)]
[ "def", "genCubeVector", "(", "x", ",", "y", ",", "z", ",", "x_mult", "=", "1", ",", "y_mult", "=", "1", ",", "z_mult", "=", "1", ")", ":", "cX", "=", "(", "x", "-", "1", ")", "/", "2.0", "cY", "=", "(", "y", "-", "1", ")", "/", "2.0", "...
Generates a map of vector lengths from the center point to each coordinate x - width of matrix to generate y - height of matrix to generate z - depth of matrix to generate x_mult - value to scale x-axis by y_mult - value to scale y-axis by z_mult - value to scale z-axis by
[ "Generates", "a", "map", "of", "vector", "lengths", "from", "the", "center", "point", "to", "each", "coordinate", "x", "-", "width", "of", "matrix", "to", "generate", "y", "-", "height", "of", "matrix", "to", "generate", "z", "-", "depth", "of", "matrix"...
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/cube/bloom.py#L5-L24
train
42,823
brosner/django-timezones
timezones/utils.py
adjust_datetime_to_timezone
def adjust_datetime_to_timezone(value, from_tz, to_tz=None): """ Given a ``datetime`` object adjust it according to the from_tz timezone string into the to_tz timezone string. """ if to_tz is None: to_tz = settings.TIME_ZONE if value.tzinfo is None: if not hasattr(from_tz, "localize"): from_tz = pytz.timezone(smart_str(from_tz)) value = from_tz.localize(value) return value.astimezone(pytz.timezone(smart_str(to_tz)))
python
def adjust_datetime_to_timezone(value, from_tz, to_tz=None): """ Given a ``datetime`` object adjust it according to the from_tz timezone string into the to_tz timezone string. """ if to_tz is None: to_tz = settings.TIME_ZONE if value.tzinfo is None: if not hasattr(from_tz, "localize"): from_tz = pytz.timezone(smart_str(from_tz)) value = from_tz.localize(value) return value.astimezone(pytz.timezone(smart_str(to_tz)))
[ "def", "adjust_datetime_to_timezone", "(", "value", ",", "from_tz", ",", "to_tz", "=", "None", ")", ":", "if", "to_tz", "is", "None", ":", "to_tz", "=", "settings", ".", "TIME_ZONE", "if", "value", ".", "tzinfo", "is", "None", ":", "if", "not", "hasattr"...
Given a ``datetime`` object adjust it according to the from_tz timezone string into the to_tz timezone string.
[ "Given", "a", "datetime", "object", "adjust", "it", "according", "to", "the", "from_tz", "timezone", "string", "into", "the", "to_tz", "timezone", "string", "." ]
43b437c39533e1832562a2c69247b89ae1af169e
https://github.com/brosner/django-timezones/blob/43b437c39533e1832562a2c69247b89ae1af169e/timezones/utils.py#L16-L27
train
42,824
brosner/django-timezones
timezones/fields.py
LocalizedDateTimeField.get_db_prep_lookup
def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=None): """ Returns field's value prepared for database lookup. """ ## convert to settings.TIME_ZONE if value.tzinfo is None: value = default_tz.localize(value) else: value = value.astimezone(default_tz) return super(LocalizedDateTimeField, self).get_db_prep_lookup(lookup_type, value, connection=connection, prepared=prepared)
python
def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=None): """ Returns field's value prepared for database lookup. """ ## convert to settings.TIME_ZONE if value.tzinfo is None: value = default_tz.localize(value) else: value = value.astimezone(default_tz) return super(LocalizedDateTimeField, self).get_db_prep_lookup(lookup_type, value, connection=connection, prepared=prepared)
[ "def", "get_db_prep_lookup", "(", "self", ",", "lookup_type", ",", "value", ",", "connection", "=", "None", ",", "prepared", "=", "None", ")", ":", "## convert to settings.TIME_ZONE", "if", "value", ".", "tzinfo", "is", "None", ":", "value", "=", "default_tz",...
Returns field's value prepared for database lookup.
[ "Returns", "field", "s", "value", "prepared", "for", "database", "lookup", "." ]
43b437c39533e1832562a2c69247b89ae1af169e
https://github.com/brosner/django-timezones/blob/43b437c39533e1832562a2c69247b89ae1af169e/timezones/fields.py#L98-L107
train
42,825
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.make_vel
def make_vel(self): "Make a set of velocities to be randomly chosen for emitted particles" self.vel = random.normal(self.vel_mu, self.vel_sigma, 16) # Make sure nothing's slower than 1/8 pixel / step for i, vel in enumerate(self.vel): if abs(vel) < 0.125 / self._size: if vel < 0: self.vel[i] = -0.125 / self._size else: self.vel[i] = 0.125 / self._size
python
def make_vel(self): "Make a set of velocities to be randomly chosen for emitted particles" self.vel = random.normal(self.vel_mu, self.vel_sigma, 16) # Make sure nothing's slower than 1/8 pixel / step for i, vel in enumerate(self.vel): if abs(vel) < 0.125 / self._size: if vel < 0: self.vel[i] = -0.125 / self._size else: self.vel[i] = 0.125 / self._size
[ "def", "make_vel", "(", "self", ")", ":", "self", ".", "vel", "=", "random", ".", "normal", "(", "self", ".", "vel_mu", ",", "self", ".", "vel_sigma", ",", "16", ")", "# Make sure nothing's slower than 1/8 pixel / step", "for", "i", ",", "vel", "in", "enum...
Make a set of velocities to be randomly chosen for emitted particles
[ "Make", "a", "set", "of", "velocities", "to", "be", "randomly", "chosen", "for", "emitted", "particles" ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L80-L89
train
42,826
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.move_emitters
def move_emitters(self): """ Move each emitter by it's velocity. Emmitters that move off the ends and are not wrapped get sacked. """ moved_emitters = [] for e_pos, e_dir, e_vel, e_range, e_color, e_pal in self.emitters: e_pos = e_pos + e_vel if e_vel > 0: if e_pos >= (self._end + 1): if self.wrap: e_pos = e_pos - (self._end + 1) + self._start else: continue # Sacked else: if e_pos < self._start: if self.wrap: e_pos = e_pos + self._end + 1 + self._start else: continue # Sacked moved_emitters.append( (e_pos, e_dir, e_vel, e_range, e_color, e_pal)) self.emitters = moved_emitters
python
def move_emitters(self): """ Move each emitter by it's velocity. Emmitters that move off the ends and are not wrapped get sacked. """ moved_emitters = [] for e_pos, e_dir, e_vel, e_range, e_color, e_pal in self.emitters: e_pos = e_pos + e_vel if e_vel > 0: if e_pos >= (self._end + 1): if self.wrap: e_pos = e_pos - (self._end + 1) + self._start else: continue # Sacked else: if e_pos < self._start: if self.wrap: e_pos = e_pos + self._end + 1 + self._start else: continue # Sacked moved_emitters.append( (e_pos, e_dir, e_vel, e_range, e_color, e_pal)) self.emitters = moved_emitters
[ "def", "move_emitters", "(", "self", ")", ":", "moved_emitters", "=", "[", "]", "for", "e_pos", ",", "e_dir", ",", "e_vel", ",", "e_range", ",", "e_color", ",", "e_pal", "in", "self", ".", "emitters", ":", "e_pos", "=", "e_pos", "+", "e_vel", "if", "...
Move each emitter by it's velocity. Emmitters that move off the ends and are not wrapped get sacked.
[ "Move", "each", "emitter", "by", "it", "s", "velocity", ".", "Emmitters", "that", "move", "off", "the", "ends", "and", "are", "not", "wrapped", "get", "sacked", "." ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L218-L243
train
42,827
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.start_new_particles
def start_new_particles(self): """ Start some new particles from the emitters. We roll the dice starts_at_once times, seeing if we can start each particle based on starts_prob. If we start, the particle gets a color form the palette and a velocity from the vel list. """ for e_pos, e_dir, e_vel, e_range, e_color, e_pal in self.emitters: for roll in range(self.starts_at_once): if random.random() < self.starts_prob: # Start one? p_vel = self.vel[random.choice(len(self.vel))] if e_dir < 0 or e_dir == 0 and random.random() > 0.5: p_vel = -p_vel self.particles.append(( p_vel, # Velocity e_pos, # Position int(e_range // abs(p_vel)), # steps to live e_pal[ random.choice(len(e_pal))], # Color 255))
python
def start_new_particles(self): """ Start some new particles from the emitters. We roll the dice starts_at_once times, seeing if we can start each particle based on starts_prob. If we start, the particle gets a color form the palette and a velocity from the vel list. """ for e_pos, e_dir, e_vel, e_range, e_color, e_pal in self.emitters: for roll in range(self.starts_at_once): if random.random() < self.starts_prob: # Start one? p_vel = self.vel[random.choice(len(self.vel))] if e_dir < 0 or e_dir == 0 and random.random() > 0.5: p_vel = -p_vel self.particles.append(( p_vel, # Velocity e_pos, # Position int(e_range // abs(p_vel)), # steps to live e_pal[ random.choice(len(e_pal))], # Color 255))
[ "def", "start_new_particles", "(", "self", ")", ":", "for", "e_pos", ",", "e_dir", ",", "e_vel", ",", "e_range", ",", "e_color", ",", "e_pal", "in", "self", ".", "emitters", ":", "for", "roll", "in", "range", "(", "self", ".", "starts_at_once", ")", ":...
Start some new particles from the emitters. We roll the dice starts_at_once times, seeing if we can start each particle based on starts_prob. If we start, the particle gets a color form the palette and a velocity from the vel list.
[ "Start", "some", "new", "particles", "from", "the", "emitters", ".", "We", "roll", "the", "dice", "starts_at_once", "times", "seeing", "if", "we", "can", "start", "each", "particle", "based", "on", "starts_prob", ".", "If", "we", "start", "the", "particle", ...
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L245-L264
train
42,828
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.visibility
def visibility(self, strip_pos, particle_pos): """ Compute particle visibility based on distance between current strip position being rendered and particle position. A value of 0.0 is returned if they are >= one aperture away, values between 0.0 and 1.0 are returned if they are less than one aperature apart. """ dist = abs(particle_pos - strip_pos) if dist > self.half_size: dist = self._size - dist if dist < self.aperture: return (self.aperture - dist) / self.aperture else: return 0
python
def visibility(self, strip_pos, particle_pos): """ Compute particle visibility based on distance between current strip position being rendered and particle position. A value of 0.0 is returned if they are >= one aperture away, values between 0.0 and 1.0 are returned if they are less than one aperature apart. """ dist = abs(particle_pos - strip_pos) if dist > self.half_size: dist = self._size - dist if dist < self.aperture: return (self.aperture - dist) / self.aperture else: return 0
[ "def", "visibility", "(", "self", ",", "strip_pos", ",", "particle_pos", ")", ":", "dist", "=", "abs", "(", "particle_pos", "-", "strip_pos", ")", "if", "dist", ">", "self", ".", "half_size", ":", "dist", "=", "self", ".", "_size", "-", "dist", "if", ...
Compute particle visibility based on distance between current strip position being rendered and particle position. A value of 0.0 is returned if they are >= one aperture away, values between 0.0 and 1.0 are returned if they are less than one aperature apart.
[ "Compute", "particle", "visibility", "based", "on", "distance", "between", "current", "strip", "position", "being", "rendered", "and", "particle", "position", ".", "A", "value", "of", "0", ".", "0", "is", "returned", "if", "they", "are", ">", "=", "one", "...
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L266-L280
train
42,829
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.render_particles
def render_particles(self): """ Render visible particles at each strip position, by modifying the strip's color list. """ for strip_pos in range(self._start, self._end + 1): blended = COLORS.black # Render visible emitters if self.has_e_colors: for (e_pos, e_dir, e_vel, e_range, e_color, e_pal) in self.emitters: if e_color is not None: vis = self.visibility(strip_pos, e_pos) if vis > 0: blended = color_blend( blended, color_scale(e_color, int(vis * 255))) # Render visible particles for vel, pos, stl, color, bright in self.particles: vis = self.visibility(strip_pos, pos) if vis > 0 and bright > 0: blended = color_blend( blended, color_scale(color, int(vis * bright))) # Add background if showing if (blended == COLORS.black): blended = self.bgcolor self.color_list[strip_pos] = blended
python
def render_particles(self): """ Render visible particles at each strip position, by modifying the strip's color list. """ for strip_pos in range(self._start, self._end + 1): blended = COLORS.black # Render visible emitters if self.has_e_colors: for (e_pos, e_dir, e_vel, e_range, e_color, e_pal) in self.emitters: if e_color is not None: vis = self.visibility(strip_pos, e_pos) if vis > 0: blended = color_blend( blended, color_scale(e_color, int(vis * 255))) # Render visible particles for vel, pos, stl, color, bright in self.particles: vis = self.visibility(strip_pos, pos) if vis > 0 and bright > 0: blended = color_blend( blended, color_scale(color, int(vis * bright))) # Add background if showing if (blended == COLORS.black): blended = self.bgcolor self.color_list[strip_pos] = blended
[ "def", "render_particles", "(", "self", ")", ":", "for", "strip_pos", "in", "range", "(", "self", ".", "_start", ",", "self", ".", "_end", "+", "1", ")", ":", "blended", "=", "COLORS", ".", "black", "# Render visible emitters", "if", "self", ".", "has_e_...
Render visible particles at each strip position, by modifying the strip's color list.
[ "Render", "visible", "particles", "at", "each", "strip", "position", "by", "modifying", "the", "strip", "s", "color", "list", "." ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L282-L314
train
42,830
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/strip/Emitter/__init__.py
Emitter.step
def step(self, amt=1): "Make a frame of the animation" self.move_particles() if self.has_moving_emitters: self.move_emitters() self.start_new_particles() self.render_particles() if self.emitters == [] and self.particles == []: self.completed = True
python
def step(self, amt=1): "Make a frame of the animation" self.move_particles() if self.has_moving_emitters: self.move_emitters() self.start_new_particles() self.render_particles() if self.emitters == [] and self.particles == []: self.completed = True
[ "def", "step", "(", "self", ",", "amt", "=", "1", ")", ":", "self", ".", "move_particles", "(", ")", "if", "self", ".", "has_moving_emitters", ":", "self", ".", "move_emitters", "(", ")", "self", ".", "start_new_particles", "(", ")", "self", ".", "rend...
Make a frame of the animation
[ "Make", "a", "frame", "of", "the", "animation" ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/strip/Emitter/__init__.py#L316-L324
train
42,831
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/matrix/TicTacToe.py
Tic.complete
def complete(self): """is the game over?""" if None not in [v for v in self.squares]: return True if self.winner() is not None: return True return False
python
def complete(self): """is the game over?""" if None not in [v for v in self.squares]: return True if self.winner() is not None: return True return False
[ "def", "complete", "(", "self", ")", ":", "if", "None", "not", "in", "[", "v", "for", "v", "in", "self", ".", "squares", "]", ":", "return", "True", "if", "self", ".", "winner", "(", ")", "is", "not", "None", ":", "return", "True", "return", "Fal...
is the game over?
[ "is", "the", "game", "over?" ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/matrix/TicTacToe.py#L32-L38
train
42,832
ManiacalLabs/BiblioPixelAnimations
BiblioPixelAnimations/matrix/TicTacToe.py
Tic.get_squares
def get_squares(self, player=None): """squares that belong to a player""" if player: return [k for k, v in enumerate(self.squares) if v == player] else: return self.squares
python
def get_squares(self, player=None): """squares that belong to a player""" if player: return [k for k, v in enumerate(self.squares) if v == player] else: return self.squares
[ "def", "get_squares", "(", "self", ",", "player", "=", "None", ")", ":", "if", "player", ":", "return", "[", "k", "for", "k", ",", "v", "in", "enumerate", "(", "self", ".", "squares", ")", "if", "v", "==", "player", "]", "else", ":", "return", "s...
squares that belong to a player
[ "squares", "that", "belong", "to", "a", "player" ]
fba81f6b94f5265272a53f462ef013df1ccdb426
https://github.com/ManiacalLabs/BiblioPixelAnimations/blob/fba81f6b94f5265272a53f462ef013df1ccdb426/BiblioPixelAnimations/matrix/TicTacToe.py#L77-L82
train
42,833
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeGly
def makeGly(segID, N, CA, C, O, geo): '''Creates a Glycine residue''' ##Create Residue Data Structure res= Residue((' ', segID, ' '), "GLY", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) ##print(res) return res
python
def makeGly(segID, N, CA, C, O, geo): '''Creates a Glycine residue''' ##Create Residue Data Structure res= Residue((' ', segID, ' '), "GLY", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) ##print(res) return res
[ "def", "makeGly", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##Create Residue Data Structure", "res", "=", "Residue", "(", "(", "' '", ",", "segID", ",", "' '", ")", ",", "\"GLY\"", ",", "' '", ")", "res", ".",...
Creates a Glycine residue
[ "Creates", "a", "Glycine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L99-L110
train
42,834
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeAla
def makeAla(segID, N, CA, C, O, geo): '''Creates an Alanine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") ##Create Residue Data Structure res = Residue((' ', segID, ' '), "ALA", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) return res
python
def makeAla(segID, N, CA, C, O, geo): '''Creates an Alanine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") ##Create Residue Data Structure res = Residue((' ', segID, ' '), "ALA", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) return res
[ "def", "makeAla", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates an Alanine residue
[ "Creates", "an", "Alanine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L112-L129
train
42,835
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeSer
def makeSer(segID, N, CA, C, O, geo): '''Creates a Serine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_OG_length=geo.CB_OG_length CA_CB_OG_angle=geo.CA_CB_OG_angle N_CA_CB_OG_diangle=geo.N_CA_CB_OG_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") oxygen_g= calculateCoordinates(N, CA, CB, CB_OG_length, CA_CB_OG_angle, N_CA_CB_OG_diangle) OG= Atom("OG", oxygen_g, 0.0, 1.0, " ", " OG", 0, "O") ##Create Reside Data Structure res= Residue((' ', segID, ' '), "SER", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(OG) ##print(res) return res
python
def makeSer(segID, N, CA, C, O, geo): '''Creates a Serine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_OG_length=geo.CB_OG_length CA_CB_OG_angle=geo.CA_CB_OG_angle N_CA_CB_OG_diangle=geo.N_CA_CB_OG_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") oxygen_g= calculateCoordinates(N, CA, CB, CB_OG_length, CA_CB_OG_angle, N_CA_CB_OG_diangle) OG= Atom("OG", oxygen_g, 0.0, 1.0, " ", " OG", 0, "O") ##Create Reside Data Structure res= Residue((' ', segID, ' '), "SER", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(OG) ##print(res) return res
[ "def", "makeSer", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Serine residue
[ "Creates", "a", "Serine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L131-L157
train
42,836
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeCys
def makeCys(segID, N, CA, C, O, geo): '''Creates a Cysteine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_SG_length= geo.CB_SG_length CA_CB_SG_angle= geo.CA_CB_SG_angle N_CA_CB_SG_diangle= geo.N_CA_CB_SG_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") sulfur_g= calculateCoordinates(N, CA, CB, CB_SG_length, CA_CB_SG_angle, N_CA_CB_SG_diangle) SG= Atom("SG", sulfur_g, 0.0, 1.0, " ", " SG", 0, "S") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "CYS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(SG) return res
python
def makeCys(segID, N, CA, C, O, geo): '''Creates a Cysteine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_SG_length= geo.CB_SG_length CA_CB_SG_angle= geo.CA_CB_SG_angle N_CA_CB_SG_diangle= geo.N_CA_CB_SG_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") sulfur_g= calculateCoordinates(N, CA, CB, CB_SG_length, CA_CB_SG_angle, N_CA_CB_SG_diangle) SG= Atom("SG", sulfur_g, 0.0, 1.0, " ", " SG", 0, "S") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "CYS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(SG) return res
[ "def", "makeCys", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Cysteine residue
[ "Creates", "a", "Cysteine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L159-L183
train
42,837
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeVal
def makeVal(segID, N, CA, C, O, geo): '''Creates a Valine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG1_length=geo.CB_CG1_length CA_CB_CG1_angle=geo.CA_CB_CG1_angle N_CA_CB_CG1_diangle=geo.N_CA_CB_CG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle=geo.N_CA_CB_CG2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle, N_CA_CB_CG1_diangle) CG1= Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "VAL", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG1) res.add(CG2) return res
python
def makeVal(segID, N, CA, C, O, geo): '''Creates a Valine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG1_length=geo.CB_CG1_length CA_CB_CG1_angle=geo.CA_CB_CG1_angle N_CA_CB_CG1_diangle=geo.N_CA_CB_CG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle=geo.N_CA_CB_CG2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle, N_CA_CB_CG1_diangle) CG1= Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "VAL", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG1) res.add(CG2) return res
[ "def", "makeVal", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Valine residue
[ "Creates", "a", "Valine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L185-L216
train
42,838
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeIle
def makeIle(segID, N, CA, C, O, geo): '''Creates an Isoleucine residue''' ##R-group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG1_length=geo.CB_CG1_length CA_CB_CG1_angle=geo.CA_CB_CG1_angle N_CA_CB_CG1_diangle=geo.N_CA_CB_CG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle= geo.N_CA_CB_CG2_diangle CG1_CD1_length= geo.CG1_CD1_length CB_CG1_CD1_angle= geo.CB_CG1_CD1_angle CA_CB_CG1_CD1_diangle= geo.CA_CB_CG1_CD1_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle, N_CA_CB_CG1_diangle) CG1= Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG1, CG1_CD1_length, CB_CG1_CD1_angle, CA_CB_CG1_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ILE", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG1) res.add(CG2) res.add(CD1) return res
python
def makeIle(segID, N, CA, C, O, geo): '''Creates an Isoleucine residue''' ##R-group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG1_length=geo.CB_CG1_length CA_CB_CG1_angle=geo.CA_CB_CG1_angle N_CA_CB_CG1_diangle=geo.N_CA_CB_CG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle= geo.N_CA_CB_CG2_diangle CG1_CD1_length= geo.CG1_CD1_length CB_CG1_CD1_angle= geo.CB_CG1_CD1_angle CA_CB_CG1_CD1_diangle= geo.CA_CB_CG1_CD1_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG1_length, CA_CB_CG1_angle, N_CA_CB_CG1_diangle) CG1= Atom("CG1", carbon_g1, 0.0, 1.0, " ", " CG1", 0, "C") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG1, CG1_CD1_length, CB_CG1_CD1_angle, CA_CB_CG1_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ILE", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG1) res.add(CG2) res.add(CD1) return res
[ "def", "makeIle", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates an Isoleucine residue
[ "Creates", "an", "Isoleucine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L218-L256
train
42,839
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeLeu
def makeLeu(segID, N, CA, C, O, geo): '''Creates a Leucine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle= geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD1_length=geo.CG_CD1_length CB_CG_CD1_angle=geo.CB_CG_CD1_angle CA_CB_CG_CD1_diangle=geo.CA_CB_CG_CD1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle=geo.CA_CB_CG_CD2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g1, 0.0, 1.0, " ", " CG", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG, CG_CD1_length, CB_CG_CD1_angle, CA_CB_CG_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "LEU", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD1) res.add(CD2) return res
python
def makeLeu(segID, N, CA, C, O, geo): '''Creates a Leucine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle= geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD1_length=geo.CG_CD1_length CB_CG_CD1_angle=geo.CB_CG_CD1_angle CA_CB_CG_CD1_diangle=geo.CA_CB_CG_CD1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle=geo.CA_CB_CG_CD2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g1= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g1, 0.0, 1.0, " ", " CG", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG, CG_CD1_length, CB_CG_CD1_angle, CA_CB_CG_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "LEU", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD1) res.add(CD2) return res
[ "def", "makeLeu", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Leucine residue
[ "Creates", "a", "Leucine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L258-L296
train
42,840
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeThr
def makeThr(segID, N, CA, C, O, geo): '''Creates a Threonine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_OG1_length=geo.CB_OG1_length CA_CB_OG1_angle=geo.CA_CB_OG1_angle N_CA_CB_OG1_diangle=geo.N_CA_CB_OG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle= geo.N_CA_CB_CG2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") oxygen_g1= calculateCoordinates(N, CA, CB, CB_OG1_length, CA_CB_OG1_angle, N_CA_CB_OG1_diangle) OG1= Atom("OG1", oxygen_g1, 0.0, 1.0, " ", " OG1", 0, "O") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "THR", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(OG1) res.add(CG2) return res
python
def makeThr(segID, N, CA, C, O, geo): '''Creates a Threonine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_OG1_length=geo.CB_OG1_length CA_CB_OG1_angle=geo.CA_CB_OG1_angle N_CA_CB_OG1_diangle=geo.N_CA_CB_OG1_diangle CB_CG2_length=geo.CB_CG2_length CA_CB_CG2_angle=geo.CA_CB_CG2_angle N_CA_CB_CG2_diangle= geo.N_CA_CB_CG2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") oxygen_g1= calculateCoordinates(N, CA, CB, CB_OG1_length, CA_CB_OG1_angle, N_CA_CB_OG1_diangle) OG1= Atom("OG1", oxygen_g1, 0.0, 1.0, " ", " OG1", 0, "O") carbon_g2= calculateCoordinates(N, CA, CB, CB_CG2_length, CA_CB_CG2_angle, N_CA_CB_CG2_diangle) CG2= Atom("CG2", carbon_g2, 0.0, 1.0, " ", " CG2", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "THR", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(OG1) res.add(CG2) return res
[ "def", "makeThr", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Threonine residue
[ "Creates", "a", "Threonine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L298-L329
train
42,841
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeArg
def makeArg(segID, N, CA, C, O, geo): '''Creates an Arginie residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle= geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_NE_length=geo.CD_NE_length CG_CD_NE_angle=geo.CG_CD_NE_angle CB_CG_CD_NE_diangle=geo.CB_CG_CD_NE_diangle NE_CZ_length=geo.NE_CZ_length CD_NE_CZ_angle=geo.CD_NE_CZ_angle CG_CD_NE_CZ_diangle=geo.CG_CD_NE_CZ_diangle CZ_NH1_length=geo.CZ_NH1_length NE_CZ_NH1_angle=geo.NE_CZ_NH1_angle CD_NE_CZ_NH1_diangle=geo.CD_NE_CZ_NH1_diangle CZ_NH2_length=geo.CZ_NH2_length NE_CZ_NH2_angle=geo.NE_CZ_NH2_angle CD_NE_CZ_NH2_diangle=geo.CD_NE_CZ_NH2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") nitrogen_e= calculateCoordinates(CB, CG, CD, CD_NE_length, CG_CD_NE_angle, CB_CG_CD_NE_diangle) NE= Atom("NE", nitrogen_e, 0.0, 1.0, " ", " NE", 0, "N") carbon_z= calculateCoordinates(CG, CD, NE, NE_CZ_length, CD_NE_CZ_angle, CG_CD_NE_CZ_diangle) CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C") nitrogen_h1= calculateCoordinates(CD, NE, CZ, CZ_NH1_length, NE_CZ_NH1_angle, CD_NE_CZ_NH1_diangle) NH1= Atom("NH1", nitrogen_h1, 0.0, 1.0, " ", " NH1", 0, "N") nitrogen_h2= calculateCoordinates(CD, NE, CZ, CZ_NH2_length, NE_CZ_NH2_angle, CD_NE_CZ_NH2_diangle) NH2= Atom("NH2", nitrogen_h2, 0.0, 1.0, " ", " NH2", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ARG", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(NE) res.add(CZ) res.add(NH1) res.add(NH2) return res
python
def makeArg(segID, N, CA, C, O, geo): '''Creates an Arginie residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle= geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_NE_length=geo.CD_NE_length CG_CD_NE_angle=geo.CG_CD_NE_angle CB_CG_CD_NE_diangle=geo.CB_CG_CD_NE_diangle NE_CZ_length=geo.NE_CZ_length CD_NE_CZ_angle=geo.CD_NE_CZ_angle CG_CD_NE_CZ_diangle=geo.CG_CD_NE_CZ_diangle CZ_NH1_length=geo.CZ_NH1_length NE_CZ_NH1_angle=geo.NE_CZ_NH1_angle CD_NE_CZ_NH1_diangle=geo.CD_NE_CZ_NH1_diangle CZ_NH2_length=geo.CZ_NH2_length NE_CZ_NH2_angle=geo.NE_CZ_NH2_angle CD_NE_CZ_NH2_diangle=geo.CD_NE_CZ_NH2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") nitrogen_e= calculateCoordinates(CB, CG, CD, CD_NE_length, CG_CD_NE_angle, CB_CG_CD_NE_diangle) NE= Atom("NE", nitrogen_e, 0.0, 1.0, " ", " NE", 0, "N") carbon_z= calculateCoordinates(CG, CD, NE, NE_CZ_length, CD_NE_CZ_angle, CG_CD_NE_CZ_diangle) CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C") nitrogen_h1= calculateCoordinates(CD, NE, CZ, CZ_NH1_length, NE_CZ_NH1_angle, CD_NE_CZ_NH1_diangle) NH1= Atom("NH1", nitrogen_h1, 0.0, 1.0, " ", " NH1", 0, "N") nitrogen_h2= calculateCoordinates(CD, NE, CZ, CZ_NH2_length, NE_CZ_NH2_angle, CD_NE_CZ_NH2_diangle) NH2= Atom("NH2", nitrogen_h2, 0.0, 1.0, " ", " NH2", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ARG", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(NE) res.add(CZ) res.add(NH1) res.add(NH2) return res
[ "def", "makeArg", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates an Arginie residue
[ "Creates", "an", "Arginie", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L331-L390
train
42,842
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeLys
def makeLys(segID, N, CA, C, O, geo): '''Creates a Lysine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_CE_length=geo.CD_CE_length CG_CD_CE_angle=geo.CG_CD_CE_angle CB_CG_CD_CE_diangle=geo.CB_CG_CD_CE_diangle CE_NZ_length=geo.CE_NZ_length CD_CE_NZ_angle=geo.CD_CE_NZ_angle CG_CD_CE_NZ_diangle=geo.CG_CD_CE_NZ_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") carbon_e= calculateCoordinates(CB, CG, CD, CD_CE_length, CG_CD_CE_angle, CB_CG_CD_CE_diangle) CE= Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C") nitrogen_z= calculateCoordinates(CG, CD, CE, CE_NZ_length, CD_CE_NZ_angle, CG_CD_CE_NZ_diangle) NZ= Atom("NZ", nitrogen_z, 0.0, 1.0, " ", " NZ", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "LYS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(CE) res.add(NZ) return res
python
def makeLys(segID, N, CA, C, O, geo): '''Creates a Lysine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_CE_length=geo.CD_CE_length CG_CD_CE_angle=geo.CG_CD_CE_angle CB_CG_CD_CE_diangle=geo.CB_CG_CD_CE_diangle CE_NZ_length=geo.CE_NZ_length CD_CE_NZ_angle=geo.CD_CE_NZ_angle CG_CD_CE_NZ_diangle=geo.CG_CD_CE_NZ_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") carbon_e= calculateCoordinates(CB, CG, CD, CD_CE_length, CG_CD_CE_angle, CB_CG_CD_CE_diangle) CE= Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C") nitrogen_z= calculateCoordinates(CG, CD, CE, CE_NZ_length, CD_CE_NZ_angle, CG_CD_CE_NZ_diangle) NZ= Atom("NZ", nitrogen_z, 0.0, 1.0, " ", " NZ", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "LYS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(CE) res.add(NZ) return res
[ "def", "makeLys", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Lysine residue
[ "Creates", "a", "Lysine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L392-L437
train
42,843
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeAsp
def makeAsp(segID, N, CA, C, O, geo): '''Creates an Aspartic Acid residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_OD1_length=geo.CG_OD1_length CB_CG_OD1_angle=geo.CB_CG_OD1_angle CA_CB_CG_OD1_diangle=geo.CA_CB_CG_OD1_diangle CG_OD2_length=geo.CG_OD2_length CB_CG_OD2_angle=geo.CB_CG_OD2_angle CA_CB_CG_OD2_diangle=geo.CA_CB_CG_OD2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") oxygen_d1= calculateCoordinates(CA, CB, CG, CG_OD1_length, CB_CG_OD1_angle, CA_CB_CG_OD1_diangle) OD1= Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O") oxygen_d2= calculateCoordinates(CA, CB, CG, CG_OD2_length, CB_CG_OD2_angle, CA_CB_CG_OD2_diangle) OD2= Atom("OD2", oxygen_d2, 0.0, 1.0, " ", " OD2", 0, "O") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ASP", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(OD1) res.add(OD2) return res
python
def makeAsp(segID, N, CA, C, O, geo): '''Creates an Aspartic Acid residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_OD1_length=geo.CG_OD1_length CB_CG_OD1_angle=geo.CB_CG_OD1_angle CA_CB_CG_OD1_diangle=geo.CA_CB_CG_OD1_diangle CG_OD2_length=geo.CG_OD2_length CB_CG_OD2_angle=geo.CB_CG_OD2_angle CA_CB_CG_OD2_diangle=geo.CA_CB_CG_OD2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") oxygen_d1= calculateCoordinates(CA, CB, CG, CG_OD1_length, CB_CG_OD1_angle, CA_CB_CG_OD1_diangle) OD1= Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O") oxygen_d2= calculateCoordinates(CA, CB, CG, CG_OD2_length, CB_CG_OD2_angle, CA_CB_CG_OD2_diangle) OD2= Atom("OD2", oxygen_d2, 0.0, 1.0, " ", " OD2", 0, "O") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "ASP", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(OD1) res.add(OD2) return res
[ "def", "makeAsp", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates an Aspartic Acid residue
[ "Creates", "an", "Aspartic", "Acid", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L439-L477
train
42,844
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeAsn
def makeAsn(segID,N, CA, C, O, geo): '''Creates an Asparagine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_OD1_length=geo.CG_OD1_length CB_CG_OD1_angle=geo.CB_CG_OD1_angle CA_CB_CG_OD1_diangle=geo.CA_CB_CG_OD1_diangle CG_ND2_length=geo.CG_ND2_length CB_CG_ND2_angle=geo.CB_CG_ND2_angle CA_CB_CG_ND2_diangle=geo.CA_CB_CG_ND2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") oxygen_d1= calculateCoordinates(CA, CB, CG, CG_OD1_length, CB_CG_OD1_angle, CA_CB_CG_OD1_diangle) OD1= Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O") nitrogen_d2= calculateCoordinates(CA, CB, CG, CG_ND2_length, CB_CG_ND2_angle, CA_CB_CG_ND2_diangle) ND2= Atom("ND2", nitrogen_d2, 0.0, 1.0, " ", " ND2", 0, "N") res= Residue((' ', segID, ' '), "ASN", ' ') ##Create Residue Data Structure res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(OD1) res.add(ND2) return res
python
def makeAsn(segID,N, CA, C, O, geo): '''Creates an Asparagine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_OD1_length=geo.CG_OD1_length CB_CG_OD1_angle=geo.CB_CG_OD1_angle CA_CB_CG_OD1_diangle=geo.CA_CB_CG_OD1_diangle CG_ND2_length=geo.CG_ND2_length CB_CG_ND2_angle=geo.CB_CG_ND2_angle CA_CB_CG_ND2_diangle=geo.CA_CB_CG_ND2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") oxygen_d1= calculateCoordinates(CA, CB, CG, CG_OD1_length, CB_CG_OD1_angle, CA_CB_CG_OD1_diangle) OD1= Atom("OD1", oxygen_d1, 0.0, 1.0, " ", " OD1", 0, "O") nitrogen_d2= calculateCoordinates(CA, CB, CG, CG_ND2_length, CB_CG_ND2_angle, CA_CB_CG_ND2_diangle) ND2= Atom("ND2", nitrogen_d2, 0.0, 1.0, " ", " ND2", 0, "N") res= Residue((' ', segID, ' '), "ASN", ' ') ##Create Residue Data Structure res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(OD1) res.add(ND2) return res
[ "def", "makeAsn", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates an Asparagine residue
[ "Creates", "an", "Asparagine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L479-L517
train
42,845
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeGlu
def makeGlu(segID, N, CA, C, O, geo): '''Creates a Glutamic Acid residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle = geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_OE1_length=geo.CD_OE1_length CG_CD_OE1_angle=geo.CG_CD_OE1_angle CB_CG_CD_OE1_diangle=geo.CB_CG_CD_OE1_diangle CD_OE2_length=geo.CD_OE2_length CG_CD_OE2_angle=geo.CG_CD_OE2_angle CB_CG_CD_OE2_diangle=geo.CB_CG_CD_OE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") oxygen_e1= calculateCoordinates(CB, CG, CD, CD_OE1_length, CG_CD_OE1_angle, CB_CG_CD_OE1_diangle) OE1= Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O") oxygen_e2= calculateCoordinates(CB, CG, CD, CD_OE2_length, CG_CD_OE2_angle, CB_CG_CD_OE2_diangle) OE2= Atom("OE2", oxygen_e2, 0.0, 1.0, " ", " OE2", 0, "O") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "GLU", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(OE1) res.add(OE2) return res
python
def makeGlu(segID, N, CA, C, O, geo): '''Creates a Glutamic Acid residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle = geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_OE1_length=geo.CD_OE1_length CG_CD_OE1_angle=geo.CG_CD_OE1_angle CB_CG_CD_OE1_diangle=geo.CB_CG_CD_OE1_diangle CD_OE2_length=geo.CD_OE2_length CG_CD_OE2_angle=geo.CG_CD_OE2_angle CB_CG_CD_OE2_diangle=geo.CB_CG_CD_OE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") oxygen_e1= calculateCoordinates(CB, CG, CD, CD_OE1_length, CG_CD_OE1_angle, CB_CG_CD_OE1_diangle) OE1= Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O") oxygen_e2= calculateCoordinates(CB, CG, CD, CD_OE2_length, CG_CD_OE2_angle, CB_CG_CD_OE2_diangle) OE2= Atom("OE2", oxygen_e2, 0.0, 1.0, " ", " OE2", 0, "O") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "GLU", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(OE1) res.add(OE2) return res
[ "def", "makeGlu", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Glutamic Acid residue
[ "Creates", "a", "Glutamic", "Acid", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L519-L565
train
42,846
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeGln
def makeGln(segID, N, CA, C, O, geo): '''Creates a Glutamine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_OE1_length=geo.CD_OE1_length CG_CD_OE1_angle=geo.CG_CD_OE1_angle CB_CG_CD_OE1_diangle=geo.CB_CG_CD_OE1_diangle CD_NE2_length=geo.CD_NE2_length CG_CD_NE2_angle=geo.CG_CD_NE2_angle CB_CG_CD_NE2_diangle=geo.CB_CG_CD_NE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") oxygen_e1= calculateCoordinates(CB, CG, CD, CD_OE1_length, CG_CD_OE1_angle, CB_CG_CD_OE1_diangle) OE1= Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O") nitrogen_e2= calculateCoordinates(CB, CG, CD, CD_NE2_length, CG_CD_NE2_angle, CB_CG_CD_NE2_diangle) NE2= Atom("NE2", nitrogen_e2, 0.0, 1.0, " ", " NE2", 0, "N") ##Create Residue DS res= Residue((' ', segID, ' '), "GLN", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(OE1) res.add(NE2) return res
python
def makeGln(segID, N, CA, C, O, geo): '''Creates a Glutamine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle CD_OE1_length=geo.CD_OE1_length CG_CD_OE1_angle=geo.CG_CD_OE1_angle CB_CG_CD_OE1_diangle=geo.CB_CG_CD_OE1_diangle CD_NE2_length=geo.CD_NE2_length CG_CD_NE2_angle=geo.CG_CD_NE2_angle CB_CG_CD_NE2_diangle=geo.CB_CG_CD_NE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") oxygen_e1= calculateCoordinates(CB, CG, CD, CD_OE1_length, CG_CD_OE1_angle, CB_CG_CD_OE1_diangle) OE1= Atom("OE1", oxygen_e1, 0.0, 1.0, " ", " OE1", 0, "O") nitrogen_e2= calculateCoordinates(CB, CG, CD, CD_NE2_length, CG_CD_NE2_angle, CB_CG_CD_NE2_diangle) NE2= Atom("NE2", nitrogen_e2, 0.0, 1.0, " ", " NE2", 0, "N") ##Create Residue DS res= Residue((' ', segID, ' '), "GLN", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) res.add(OE1) res.add(NE2) return res
[ "def", "makeGln", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Glutamine residue
[ "Creates", "a", "Glutamine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L567-L614
train
42,847
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeMet
def makeMet(segID, N, CA, C, O, geo): '''Creates a Methionine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_SD_length=geo.CG_SD_length CB_CG_SD_angle=geo.CB_CG_SD_angle CA_CB_CG_SD_diangle=geo.CA_CB_CG_SD_diangle SD_CE_length=geo.SD_CE_length CG_SD_CE_angle=geo.CG_SD_CE_angle CB_CG_SD_CE_diangle=geo.CB_CG_SD_CE_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") sulfur_d= calculateCoordinates(CA, CB, CG, CG_SD_length, CB_CG_SD_angle, CA_CB_CG_SD_diangle) SD= Atom("SD", sulfur_d, 0.0, 1.0, " ", " SD", 0, "S") carbon_e= calculateCoordinates(CB, CG, SD, SD_CE_length, CG_SD_CE_angle, CB_CG_SD_CE_diangle) CE= Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "MET", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(SD) res.add(CE) return res
python
def makeMet(segID, N, CA, C, O, geo): '''Creates a Methionine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_SD_length=geo.CG_SD_length CB_CG_SD_angle=geo.CB_CG_SD_angle CA_CB_CG_SD_diangle=geo.CA_CB_CG_SD_diangle SD_CE_length=geo.SD_CE_length CG_SD_CE_angle=geo.CG_SD_CE_angle CB_CG_SD_CE_diangle=geo.CB_CG_SD_CE_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") sulfur_d= calculateCoordinates(CA, CB, CG, CG_SD_length, CB_CG_SD_angle, CA_CB_CG_SD_diangle) SD= Atom("SD", sulfur_d, 0.0, 1.0, " ", " SD", 0, "S") carbon_e= calculateCoordinates(CB, CG, SD, SD_CE_length, CG_SD_CE_angle, CB_CG_SD_CE_diangle) CE= Atom("CE", carbon_e, 0.0, 1.0, " ", " CE", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "MET", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(SD) res.add(CE) return res
[ "def", "makeMet", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Methionine residue
[ "Creates", "a", "Methionine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L616-L654
train
42,848
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makeHis
def makeHis(segID, N, CA, C, O, geo): '''Creates a Histidine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_ND1_length=geo.CG_ND1_length CB_CG_ND1_angle=geo.CB_CG_ND1_angle CA_CB_CG_ND1_diangle=geo.CA_CB_CG_ND1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle=geo.CA_CB_CG_CD2_diangle ND1_CE1_length=geo.ND1_CE1_length CG_ND1_CE1_angle=geo.CG_ND1_CE1_angle CB_CG_ND1_CE1_diangle=geo.CB_CG_ND1_CE1_diangle CD2_NE2_length=geo.CD2_NE2_length CG_CD2_NE2_angle=geo.CG_CD2_NE2_angle CB_CG_CD2_NE2_diangle=geo.CB_CG_CD2_NE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") nitrogen_d1= calculateCoordinates(CA, CB, CG, CG_ND1_length, CB_CG_ND1_angle, CA_CB_CG_ND1_diangle) ND1= Atom("ND1", nitrogen_d1, 0.0, 1.0, " ", " ND1", 0, "N") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") carbon_e1= calculateCoordinates(CB, CG, ND1, ND1_CE1_length, CG_ND1_CE1_angle, CB_CG_ND1_CE1_diangle) CE1= Atom("CE1", carbon_e1, 0.0, 1.0, " ", " CE1", 0, "C") nitrogen_e2= calculateCoordinates(CB, CG, CD2, CD2_NE2_length, CG_CD2_NE2_angle, CB_CG_CD2_NE2_diangle) NE2= Atom("NE2", nitrogen_e2, 0.0, 1.0, " ", " NE2", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "HIS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(ND1) res.add(CD2) res.add(CE1) res.add(NE2) return res
python
def makeHis(segID, N, CA, C, O, geo): '''Creates a Histidine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_ND1_length=geo.CG_ND1_length CB_CG_ND1_angle=geo.CB_CG_ND1_angle CA_CB_CG_ND1_diangle=geo.CA_CB_CG_ND1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle=geo.CA_CB_CG_CD2_diangle ND1_CE1_length=geo.ND1_CE1_length CG_ND1_CE1_angle=geo.CG_ND1_CE1_angle CB_CG_ND1_CE1_diangle=geo.CB_CG_ND1_CE1_diangle CD2_NE2_length=geo.CD2_NE2_length CG_CD2_NE2_angle=geo.CG_CD2_NE2_angle CB_CG_CD2_NE2_diangle=geo.CB_CG_CD2_NE2_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") nitrogen_d1= calculateCoordinates(CA, CB, CG, CG_ND1_length, CB_CG_ND1_angle, CA_CB_CG_ND1_diangle) ND1= Atom("ND1", nitrogen_d1, 0.0, 1.0, " ", " ND1", 0, "N") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") carbon_e1= calculateCoordinates(CB, CG, ND1, ND1_CE1_length, CG_ND1_CE1_angle, CB_CG_ND1_CE1_diangle) CE1= Atom("CE1", carbon_e1, 0.0, 1.0, " ", " CE1", 0, "C") nitrogen_e2= calculateCoordinates(CB, CG, CD2, CD2_NE2_length, CG_CD2_NE2_angle, CB_CG_CD2_NE2_diangle) NE2= Atom("NE2", nitrogen_e2, 0.0, 1.0, " ", " NE2", 0, "N") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "HIS", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(ND1) res.add(CD2) res.add(CE1) res.add(NE2) return res
[ "def", "makeHis", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Histidine residue
[ "Creates", "a", "Histidine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L656-L708
train
42,849
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makePro
def makePro(segID, N, CA, C, O, geo): '''Creates a Proline residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "PRO", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) return res
python
def makePro(segID, N, CA, C, O, geo): '''Creates a Proline residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD_length=geo.CG_CD_length CB_CG_CD_angle=geo.CB_CG_CD_angle CA_CB_CG_CD_diangle=geo.CA_CB_CG_CD_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d= calculateCoordinates(CA, CB, CG, CG_CD_length, CB_CG_CD_angle, CA_CB_CG_CD_diangle) CD= Atom("CD", carbon_d, 0.0, 1.0, " ", " CD", 0, "C") ##Create Residue Data Structure res= Residue((' ', segID, ' '), "PRO", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD) return res
[ "def", "makePro", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Proline residue
[ "Creates", "a", "Proline", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L710-L743
train
42,850
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
makePhe
def makePhe(segID, N, CA, C, O, geo): '''Creates a Phenylalanine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD1_length=geo.CG_CD1_length CB_CG_CD1_angle=geo.CB_CG_CD1_angle CA_CB_CG_CD1_diangle=geo.CA_CB_CG_CD1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle= geo.CA_CB_CG_CD2_diangle CD1_CE1_length=geo.CD1_CE1_length CG_CD1_CE1_angle=geo.CG_CD1_CE1_angle CB_CG_CD1_CE1_diangle=geo.CB_CG_CD1_CE1_diangle CD2_CE2_length=geo.CD2_CE2_length CG_CD2_CE2_angle=geo.CG_CD2_CE2_angle CB_CG_CD2_CE2_diangle=geo.CB_CG_CD2_CE2_diangle CE1_CZ_length=geo.CE1_CZ_length CD1_CE1_CZ_angle=geo.CD1_CE1_CZ_angle CG_CD1_CE1_CZ_diangle=geo.CG_CD1_CE1_CZ_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG, CG_CD1_length, CB_CG_CD1_angle, CA_CB_CG_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") carbon_e1= calculateCoordinates(CB, CG, CD1, CD1_CE1_length, CG_CD1_CE1_angle, CB_CG_CD1_CE1_diangle) CE1= Atom("CE1", carbon_e1, 0.0, 1.0, " ", " CE1", 0, "C") carbon_e2= calculateCoordinates(CB, CG, CD2, CD2_CE2_length, CG_CD2_CE2_angle, CB_CG_CD2_CE2_diangle) CE2= Atom("CE2", carbon_e2, 0.0, 1.0, " ", " CE2", 0, "C") carbon_z= calculateCoordinates(CG, CD1, CE1, CE1_CZ_length, CD1_CE1_CZ_angle, CG_CD1_CE1_CZ_diangle) CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C") ##Create Residue Data Structures res= Residue((' ', segID, ' '), "PHE", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD1) res.add(CE1) res.add(CD2) res.add(CE2) res.add(CZ) return res
python
def makePhe(segID, N, CA, C, O, geo): '''Creates a Phenylalanine residue''' ##R-Group CA_CB_length=geo.CA_CB_length C_CA_CB_angle=geo.C_CA_CB_angle N_C_CA_CB_diangle=geo.N_C_CA_CB_diangle CB_CG_length=geo.CB_CG_length CA_CB_CG_angle=geo.CA_CB_CG_angle N_CA_CB_CG_diangle=geo.N_CA_CB_CG_diangle CG_CD1_length=geo.CG_CD1_length CB_CG_CD1_angle=geo.CB_CG_CD1_angle CA_CB_CG_CD1_diangle=geo.CA_CB_CG_CD1_diangle CG_CD2_length=geo.CG_CD2_length CB_CG_CD2_angle=geo.CB_CG_CD2_angle CA_CB_CG_CD2_diangle= geo.CA_CB_CG_CD2_diangle CD1_CE1_length=geo.CD1_CE1_length CG_CD1_CE1_angle=geo.CG_CD1_CE1_angle CB_CG_CD1_CE1_diangle=geo.CB_CG_CD1_CE1_diangle CD2_CE2_length=geo.CD2_CE2_length CG_CD2_CE2_angle=geo.CG_CD2_CE2_angle CB_CG_CD2_CE2_diangle=geo.CB_CG_CD2_CE2_diangle CE1_CZ_length=geo.CE1_CZ_length CD1_CE1_CZ_angle=geo.CD1_CE1_CZ_angle CG_CD1_CE1_CZ_diangle=geo.CG_CD1_CE1_CZ_diangle carbon_b= calculateCoordinates(N, C, CA, CA_CB_length, C_CA_CB_angle, N_C_CA_CB_diangle) CB= Atom("CB", carbon_b, 0.0 , 1.0, " "," CB", 0,"C") carbon_g= calculateCoordinates(N, CA, CB, CB_CG_length, CA_CB_CG_angle, N_CA_CB_CG_diangle) CG= Atom("CG", carbon_g, 0.0, 1.0, " ", " CG", 0, "C") carbon_d1= calculateCoordinates(CA, CB, CG, CG_CD1_length, CB_CG_CD1_angle, CA_CB_CG_CD1_diangle) CD1= Atom("CD1", carbon_d1, 0.0, 1.0, " ", " CD1", 0, "C") carbon_d2= calculateCoordinates(CA, CB, CG, CG_CD2_length, CB_CG_CD2_angle, CA_CB_CG_CD2_diangle) CD2= Atom("CD2", carbon_d2, 0.0, 1.0, " ", " CD2", 0, "C") carbon_e1= calculateCoordinates(CB, CG, CD1, CD1_CE1_length, CG_CD1_CE1_angle, CB_CG_CD1_CE1_diangle) CE1= Atom("CE1", carbon_e1, 0.0, 1.0, " ", " CE1", 0, "C") carbon_e2= calculateCoordinates(CB, CG, CD2, CD2_CE2_length, CG_CD2_CE2_angle, CB_CG_CD2_CE2_diangle) CE2= Atom("CE2", carbon_e2, 0.0, 1.0, " ", " CE2", 0, "C") carbon_z= calculateCoordinates(CG, CD1, CE1, CE1_CZ_length, CD1_CE1_CZ_angle, CG_CD1_CE1_CZ_diangle) CZ= Atom("CZ", carbon_z, 0.0, 1.0, " ", " CZ", 0, "C") ##Create Residue Data Structures res= Residue((' ', segID, ' '), "PHE", ' ') res.add(N) res.add(CA) res.add(C) res.add(O) res.add(CB) res.add(CG) res.add(CD1) res.add(CE1) res.add(CD2) res.add(CE2) res.add(CZ) return res
[ "def", "makePhe", "(", "segID", ",", "N", ",", "CA", ",", "C", ",", "O", ",", "geo", ")", ":", "##R-Group", "CA_CB_length", "=", "geo", ".", "CA_CB_length", "C_CA_CB_angle", "=", "geo", ".", "C_CA_CB_angle", "N_C_CA_CB_diangle", "=", "geo", ".", "N_C_CA_...
Creates a Phenylalanine residue
[ "Creates", "a", "Phenylalanine", "residue" ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L745-L804
train
42,851
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
make_extended_structure
def make_extended_structure(AA_chain): '''Place a sequence of amino acids into a peptide in the extended conformation. The argument AA_chain holds the sequence of amino acids to be used.''' geo = geometry(AA_chain[0]) struc=initialize_res(geo) for i in range(1,len(AA_chain)): AA = AA_chain[i] geo = geometry(AA) add_residue(struc, geo) return struc
python
def make_extended_structure(AA_chain): '''Place a sequence of amino acids into a peptide in the extended conformation. The argument AA_chain holds the sequence of amino acids to be used.''' geo = geometry(AA_chain[0]) struc=initialize_res(geo) for i in range(1,len(AA_chain)): AA = AA_chain[i] geo = geometry(AA) add_residue(struc, geo) return struc
[ "def", "make_extended_structure", "(", "AA_chain", ")", ":", "geo", "=", "geometry", "(", "AA_chain", "[", "0", "]", ")", "struc", "=", "initialize_res", "(", "geo", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "AA_chain", ")", ")", ":"...
Place a sequence of amino acids into a peptide in the extended conformation. The argument AA_chain holds the sequence of amino acids to be used.
[ "Place", "a", "sequence", "of", "amino", "acids", "into", "a", "peptide", "in", "the", "extended", "conformation", ".", "The", "argument", "AA_chain", "holds", "the", "sequence", "of", "amino", "acids", "to", "be", "used", "." ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L1160-L1172
train
42,852
mtien/PeptideBuilder
PeptideBuilder/PeptideBuilder.py
make_structure_from_geos
def make_structure_from_geos(geos): '''Creates a structure out of a list of geometry objects.''' model_structure=initialize_res(geos[0]) for i in range(1,len(geos)): model_structure=add_residue(model_structure, geos[i]) return model_structure
python
def make_structure_from_geos(geos): '''Creates a structure out of a list of geometry objects.''' model_structure=initialize_res(geos[0]) for i in range(1,len(geos)): model_structure=add_residue(model_structure, geos[i]) return model_structure
[ "def", "make_structure_from_geos", "(", "geos", ")", ":", "model_structure", "=", "initialize_res", "(", "geos", "[", "0", "]", ")", "for", "i", "in", "range", "(", "1", ",", "len", "(", "geos", ")", ")", ":", "model_structure", "=", "add_residue", "(", ...
Creates a structure out of a list of geometry objects.
[ "Creates", "a", "structure", "out", "of", "a", "list", "of", "geometry", "objects", "." ]
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/PeptideBuilder.py#L1224-L1230
train
42,853
mtien/PeptideBuilder
PeptideBuilder/Geometry.py
geometry
def geometry(AA): '''Generates the geometry of the requested amino acid. The amino acid needs to be specified by its single-letter code. If an invalid code is specified, the function returns the geometry of Glycine.''' if(AA=='G'): return GlyGeo() elif(AA=='A'): return AlaGeo() elif(AA=='S'): return SerGeo() elif(AA=='C'): return CysGeo() elif(AA=='V'): return ValGeo() elif(AA=='I'): return IleGeo() elif(AA=='L'): return LeuGeo() elif(AA=='T'): return ThrGeo() elif(AA=='R'): return ArgGeo() elif(AA=='K'): return LysGeo() elif(AA=='D'): return AspGeo() elif(AA=='E'): return GluGeo() elif(AA=='N'): return AsnGeo() elif(AA=='Q'): return GlnGeo() elif(AA=='M'): return MetGeo() elif(AA=='H'): return HisGeo() elif(AA=='P'): return ProGeo() elif(AA=='F'): return PheGeo() elif(AA=='Y'): return TyrGeo() elif(AA=='W'): return TrpGeo() else: return GlyGeo()
python
def geometry(AA): '''Generates the geometry of the requested amino acid. The amino acid needs to be specified by its single-letter code. If an invalid code is specified, the function returns the geometry of Glycine.''' if(AA=='G'): return GlyGeo() elif(AA=='A'): return AlaGeo() elif(AA=='S'): return SerGeo() elif(AA=='C'): return CysGeo() elif(AA=='V'): return ValGeo() elif(AA=='I'): return IleGeo() elif(AA=='L'): return LeuGeo() elif(AA=='T'): return ThrGeo() elif(AA=='R'): return ArgGeo() elif(AA=='K'): return LysGeo() elif(AA=='D'): return AspGeo() elif(AA=='E'): return GluGeo() elif(AA=='N'): return AsnGeo() elif(AA=='Q'): return GlnGeo() elif(AA=='M'): return MetGeo() elif(AA=='H'): return HisGeo() elif(AA=='P'): return ProGeo() elif(AA=='F'): return PheGeo() elif(AA=='Y'): return TyrGeo() elif(AA=='W'): return TrpGeo() else: return GlyGeo()
[ "def", "geometry", "(", "AA", ")", ":", "if", "(", "AA", "==", "'G'", ")", ":", "return", "GlyGeo", "(", ")", "elif", "(", "AA", "==", "'A'", ")", ":", "return", "AlaGeo", "(", ")", "elif", "(", "AA", "==", "'S'", ")", ":", "return", "SerGeo", ...
Generates the geometry of the requested amino acid. The amino acid needs to be specified by its single-letter code. If an invalid code is specified, the function returns the geometry of Glycine.
[ "Generates", "the", "geometry", "of", "the", "requested", "amino", "acid", ".", "The", "amino", "acid", "needs", "to", "be", "specified", "by", "its", "single", "-", "letter", "code", ".", "If", "an", "invalid", "code", "is", "specified", "the", "function"...
7b1ddab5199432c1aabc371a34ec42dd386dfa6f
https://github.com/mtien/PeptideBuilder/blob/7b1ddab5199432c1aabc371a34ec42dd386dfa6f/PeptideBuilder/Geometry.py#L1046-L1092
train
42,854
twisted/vertex
vertex/q2qclient.py
enregister
def enregister(svc, newAddress, password): """ Register a new account and return a Deferred that fires if it worked. @param svc: a Q2QService @param newAddress: a Q2QAddress object @param password: a shared secret (str) """ return svc.connectQ2Q(q2q.Q2QAddress("",""), q2q.Q2QAddress(newAddress.domain, "accounts"), 'identity-admin', protocol.ClientFactory.forProtocol(AMP) ).addCallback( AMP.callRemote, AddUser, name=newAddress.resource, password=password ).addErrback( Failure.trap, error.ConnectionDone )
python
def enregister(svc, newAddress, password): """ Register a new account and return a Deferred that fires if it worked. @param svc: a Q2QService @param newAddress: a Q2QAddress object @param password: a shared secret (str) """ return svc.connectQ2Q(q2q.Q2QAddress("",""), q2q.Q2QAddress(newAddress.domain, "accounts"), 'identity-admin', protocol.ClientFactory.forProtocol(AMP) ).addCallback( AMP.callRemote, AddUser, name=newAddress.resource, password=password ).addErrback( Failure.trap, error.ConnectionDone )
[ "def", "enregister", "(", "svc", ",", "newAddress", ",", "password", ")", ":", "return", "svc", ".", "connectQ2Q", "(", "q2q", ".", "Q2QAddress", "(", "\"\"", ",", "\"\"", ")", ",", "q2q", ".", "Q2QAddress", "(", "newAddress", ".", "domain", ",", "\"ac...
Register a new account and return a Deferred that fires if it worked. @param svc: a Q2QService @param newAddress: a Q2QAddress object @param password: a shared secret (str)
[ "Register", "a", "new", "account", "and", "return", "a", "Deferred", "that", "fires", "if", "it", "worked", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/q2qclient.py#L321-L343
train
42,855
twisted/vertex
vertex/conncache.py
ConnectionCache.connectCached
def connectCached(self, endpoint, protocolFactory, extraWork=lambda x: x, extraHash=None): """ See module docstring @param endpoint: @param protocolFactory: @param extraWork: @param extraHash: @return: the D """ key = endpoint, extraHash D = Deferred() if key in self.cachedConnections: D.callback(self.cachedConnections[key]) elif key in self.inProgress: self.inProgress[key].append(D) else: self.inProgress[key] = [D] endpoint.connect( _CachingClientFactory( self, key, protocolFactory, extraWork)) return D
python
def connectCached(self, endpoint, protocolFactory, extraWork=lambda x: x, extraHash=None): """ See module docstring @param endpoint: @param protocolFactory: @param extraWork: @param extraHash: @return: the D """ key = endpoint, extraHash D = Deferred() if key in self.cachedConnections: D.callback(self.cachedConnections[key]) elif key in self.inProgress: self.inProgress[key].append(D) else: self.inProgress[key] = [D] endpoint.connect( _CachingClientFactory( self, key, protocolFactory, extraWork)) return D
[ "def", "connectCached", "(", "self", ",", "endpoint", ",", "protocolFactory", ",", "extraWork", "=", "lambda", "x", ":", "x", ",", "extraHash", "=", "None", ")", ":", "key", "=", "endpoint", ",", "extraHash", "D", "=", "Deferred", "(", ")", "if", "key"...
See module docstring @param endpoint: @param protocolFactory: @param extraWork: @param extraHash: @return: the D
[ "See", "module", "docstring" ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/conncache.py#L44-L69
train
42,856
twisted/vertex
vertex/conncache.py
ConnectionCache.connectionLostForKey
def connectionLostForKey(self, key): """ Remove lost connection from cache. @param key: key of connection that was lost @type key: L{tuple} of L{IAddress} and C{extraHash} """ if key in self.cachedConnections: del self.cachedConnections[key] if self._shuttingDown and self._shuttingDown.get(key): d, self._shuttingDown[key] = self._shuttingDown[key], None d.callback(None)
python
def connectionLostForKey(self, key): """ Remove lost connection from cache. @param key: key of connection that was lost @type key: L{tuple} of L{IAddress} and C{extraHash} """ if key in self.cachedConnections: del self.cachedConnections[key] if self._shuttingDown and self._shuttingDown.get(key): d, self._shuttingDown[key] = self._shuttingDown[key], None d.callback(None)
[ "def", "connectionLostForKey", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "cachedConnections", ":", "del", "self", ".", "cachedConnections", "[", "key", "]", "if", "self", ".", "_shuttingDown", "and", "self", ".", "_shuttingDown", "...
Remove lost connection from cache. @param key: key of connection that was lost @type key: L{tuple} of L{IAddress} and C{extraHash}
[ "Remove", "lost", "connection", "from", "cache", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/conncache.py#L83-L94
train
42,857
twisted/vertex
vertex/conncache.py
ConnectionCache.shutdown
def shutdown(self): """ Disconnect all cached connections. @returns: a deferred that fires once all connection are disconnected. @rtype: L{Deferred} """ self._shuttingDown = {key: Deferred() for key in self.cachedConnections.keys()} return DeferredList( [maybeDeferred(p.transport.loseConnection) for p in self.cachedConnections.values()] + self._shuttingDown.values())
python
def shutdown(self): """ Disconnect all cached connections. @returns: a deferred that fires once all connection are disconnected. @rtype: L{Deferred} """ self._shuttingDown = {key: Deferred() for key in self.cachedConnections.keys()} return DeferredList( [maybeDeferred(p.transport.loseConnection) for p in self.cachedConnections.values()] + self._shuttingDown.values())
[ "def", "shutdown", "(", "self", ")", ":", "self", ".", "_shuttingDown", "=", "{", "key", ":", "Deferred", "(", ")", "for", "key", "in", "self", ".", "cachedConnections", ".", "keys", "(", ")", "}", "return", "DeferredList", "(", "[", "maybeDeferred", "...
Disconnect all cached connections. @returns: a deferred that fires once all connection are disconnected. @rtype: L{Deferred}
[ "Disconnect", "all", "cached", "connections", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/conncache.py#L103-L115
train
42,858
mikeboers/Flask-ACL
flask_acl/state.py
parse_state
def parse_state(state): """Convert a bool, or string, into a bool. The string pairs we respond to (case insensitively) are: - ALLOW & DENY - GRANT & REJECT :returns bool: ``True`` or ``False``. :raises ValueError: when not a ``bool`` or one of the above strings. E.g.:: >>> parse_state('Allow') True """ if isinstance(state, bool): return state if not isinstance(state, basestring): raise TypeError('ACL state must be bool or string') try: return _state_strings[state.lower()] except KeyError: raise ValueError('unknown ACL state string')
python
def parse_state(state): """Convert a bool, or string, into a bool. The string pairs we respond to (case insensitively) are: - ALLOW & DENY - GRANT & REJECT :returns bool: ``True`` or ``False``. :raises ValueError: when not a ``bool`` or one of the above strings. E.g.:: >>> parse_state('Allow') True """ if isinstance(state, bool): return state if not isinstance(state, basestring): raise TypeError('ACL state must be bool or string') try: return _state_strings[state.lower()] except KeyError: raise ValueError('unknown ACL state string')
[ "def", "parse_state", "(", "state", ")", ":", "if", "isinstance", "(", "state", ",", "bool", ")", ":", "return", "state", "if", "not", "isinstance", "(", "state", ",", "basestring", ")", ":", "raise", "TypeError", "(", "'ACL state must be bool or string'", "...
Convert a bool, or string, into a bool. The string pairs we respond to (case insensitively) are: - ALLOW & DENY - GRANT & REJECT :returns bool: ``True`` or ``False``. :raises ValueError: when not a ``bool`` or one of the above strings. E.g.:: >>> parse_state('Allow') True
[ "Convert", "a", "bool", "or", "string", "into", "a", "bool", "." ]
7339b89f96ad8686d1526e25c138244ad912e12d
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/state.py#L7-L31
train
42,859
Yelp/pyramid_zipkin
pyramid_zipkin/tween.py
_getattr_path
def _getattr_path(obj, path): """ getattr for a dot separated path If an AttributeError is raised, it will return None. """ if not path: return None for attr in path.split('.'): obj = getattr(obj, attr, None) return obj
python
def _getattr_path(obj, path): """ getattr for a dot separated path If an AttributeError is raised, it will return None. """ if not path: return None for attr in path.split('.'): obj = getattr(obj, attr, None) return obj
[ "def", "_getattr_path", "(", "obj", ",", "path", ")", ":", "if", "not", "path", ":", "return", "None", "for", "attr", "in", "path", ".", "split", "(", "'.'", ")", ":", "obj", "=", "getattr", "(", "obj", ",", "attr", ",", "None", ")", "return", "o...
getattr for a dot separated path If an AttributeError is raised, it will return None.
[ "getattr", "for", "a", "dot", "separated", "path" ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/tween.py#L16-L27
train
42,860
Yelp/pyramid_zipkin
pyramid_zipkin/tween.py
_get_settings_from_request
def _get_settings_from_request(request): """Extracts Zipkin attributes and configuration from request attributes. See the `zipkin_span` context in py-zipkin for more detaied information on all the settings. Here are the supported Pyramid registry settings: zipkin.create_zipkin_attr: allows the service to override the creation of Zipkin attributes. For example, if you want to deterministically calculate trace ID from some service-specific attributes. zipkin.transport_handler: how py-zipkin will log the spans it generates. zipkin.stream_name: an additional parameter to be used as the first arg to the transport_handler function. A good example is a Kafka topic. zipkin.add_logging_annotation: if true, the outermost span in this service will have an annotation set when py-zipkin begins its logging. zipkin.report_root_timestamp: if true, the outermost span in this service will set its timestamp and duration attributes. Use this only if this service is not going to have a corresponding client span. See https://github.com/Yelp/pyramid_zipkin/issues/68 zipkin.firehose_handler: [EXPERIMENTAL] this enables "firehose tracing", which will log 100% of the spans to this handler, regardless of sampling decision. This is experimental and may change or be removed at any time without warning. zipkin.use_pattern_as_span_name: if true, we'll use the pyramid route pattern as span name. If false (default) we'll keep using the raw url path. """ settings = request.registry.settings # Creates zipkin_attrs and attaches a zipkin_trace_id attr to the request if 'zipkin.create_zipkin_attr' in settings: zipkin_attrs = settings['zipkin.create_zipkin_attr'](request) else: zipkin_attrs = create_zipkin_attr(request) if 'zipkin.transport_handler' in settings: transport_handler = settings['zipkin.transport_handler'] if not isinstance(transport_handler, BaseTransportHandler): warnings.warn( 'Using a function as transport_handler is deprecated. ' 'Please extend py_zipkin.transport.BaseTransportHandler', DeprecationWarning, ) stream_name = settings.get('zipkin.stream_name', 'zipkin') transport_handler = functools.partial(transport_handler, stream_name) else: raise ZipkinError( "`zipkin.transport_handler` is a required config property, which" " is missing. Have a look at py_zipkin's docs for how to implement" " it: https://github.com/Yelp/py_zipkin#transport" ) context_stack = _getattr_path(request, settings.get('zipkin.request_context')) service_name = settings.get('service_name', 'unknown') span_name = '{0} {1}'.format(request.method, request.path) add_logging_annotation = settings.get( 'zipkin.add_logging_annotation', False, ) # If the incoming request doesn't have Zipkin headers, this request is # assumed to be the root span of a trace. There's also a configuration # override to allow services to write their own logic for reporting # timestamp/duration. if 'zipkin.report_root_timestamp' in settings: report_root_timestamp = settings['zipkin.report_root_timestamp'] else: report_root_timestamp = 'X-B3-TraceId' not in request.headers zipkin_host = settings.get('zipkin.host') zipkin_port = settings.get('zipkin.port', request.server_port) firehose_handler = settings.get('zipkin.firehose_handler') post_handler_hook = settings.get('zipkin.post_handler_hook') max_span_batch_size = settings.get('zipkin.max_span_batch_size') use_pattern_as_span_name = bool( settings.get('zipkin.use_pattern_as_span_name', False), ) encoding = settings.get('zipkin.encoding', Encoding.V1_THRIFT) return _ZipkinSettings( zipkin_attrs, transport_handler, service_name, span_name, add_logging_annotation, report_root_timestamp, zipkin_host, zipkin_port, context_stack, firehose_handler, post_handler_hook, max_span_batch_size, use_pattern_as_span_name, encoding=encoding, )
python
def _get_settings_from_request(request): """Extracts Zipkin attributes and configuration from request attributes. See the `zipkin_span` context in py-zipkin for more detaied information on all the settings. Here are the supported Pyramid registry settings: zipkin.create_zipkin_attr: allows the service to override the creation of Zipkin attributes. For example, if you want to deterministically calculate trace ID from some service-specific attributes. zipkin.transport_handler: how py-zipkin will log the spans it generates. zipkin.stream_name: an additional parameter to be used as the first arg to the transport_handler function. A good example is a Kafka topic. zipkin.add_logging_annotation: if true, the outermost span in this service will have an annotation set when py-zipkin begins its logging. zipkin.report_root_timestamp: if true, the outermost span in this service will set its timestamp and duration attributes. Use this only if this service is not going to have a corresponding client span. See https://github.com/Yelp/pyramid_zipkin/issues/68 zipkin.firehose_handler: [EXPERIMENTAL] this enables "firehose tracing", which will log 100% of the spans to this handler, regardless of sampling decision. This is experimental and may change or be removed at any time without warning. zipkin.use_pattern_as_span_name: if true, we'll use the pyramid route pattern as span name. If false (default) we'll keep using the raw url path. """ settings = request.registry.settings # Creates zipkin_attrs and attaches a zipkin_trace_id attr to the request if 'zipkin.create_zipkin_attr' in settings: zipkin_attrs = settings['zipkin.create_zipkin_attr'](request) else: zipkin_attrs = create_zipkin_attr(request) if 'zipkin.transport_handler' in settings: transport_handler = settings['zipkin.transport_handler'] if not isinstance(transport_handler, BaseTransportHandler): warnings.warn( 'Using a function as transport_handler is deprecated. ' 'Please extend py_zipkin.transport.BaseTransportHandler', DeprecationWarning, ) stream_name = settings.get('zipkin.stream_name', 'zipkin') transport_handler = functools.partial(transport_handler, stream_name) else: raise ZipkinError( "`zipkin.transport_handler` is a required config property, which" " is missing. Have a look at py_zipkin's docs for how to implement" " it: https://github.com/Yelp/py_zipkin#transport" ) context_stack = _getattr_path(request, settings.get('zipkin.request_context')) service_name = settings.get('service_name', 'unknown') span_name = '{0} {1}'.format(request.method, request.path) add_logging_annotation = settings.get( 'zipkin.add_logging_annotation', False, ) # If the incoming request doesn't have Zipkin headers, this request is # assumed to be the root span of a trace. There's also a configuration # override to allow services to write their own logic for reporting # timestamp/duration. if 'zipkin.report_root_timestamp' in settings: report_root_timestamp = settings['zipkin.report_root_timestamp'] else: report_root_timestamp = 'X-B3-TraceId' not in request.headers zipkin_host = settings.get('zipkin.host') zipkin_port = settings.get('zipkin.port', request.server_port) firehose_handler = settings.get('zipkin.firehose_handler') post_handler_hook = settings.get('zipkin.post_handler_hook') max_span_batch_size = settings.get('zipkin.max_span_batch_size') use_pattern_as_span_name = bool( settings.get('zipkin.use_pattern_as_span_name', False), ) encoding = settings.get('zipkin.encoding', Encoding.V1_THRIFT) return _ZipkinSettings( zipkin_attrs, transport_handler, service_name, span_name, add_logging_annotation, report_root_timestamp, zipkin_host, zipkin_port, context_stack, firehose_handler, post_handler_hook, max_span_batch_size, use_pattern_as_span_name, encoding=encoding, )
[ "def", "_get_settings_from_request", "(", "request", ")", ":", "settings", "=", "request", ".", "registry", ".", "settings", "# Creates zipkin_attrs and attaches a zipkin_trace_id attr to the request", "if", "'zipkin.create_zipkin_attr'", "in", "settings", ":", "zipkin_attrs", ...
Extracts Zipkin attributes and configuration from request attributes. See the `zipkin_span` context in py-zipkin for more detaied information on all the settings. Here are the supported Pyramid registry settings: zipkin.create_zipkin_attr: allows the service to override the creation of Zipkin attributes. For example, if you want to deterministically calculate trace ID from some service-specific attributes. zipkin.transport_handler: how py-zipkin will log the spans it generates. zipkin.stream_name: an additional parameter to be used as the first arg to the transport_handler function. A good example is a Kafka topic. zipkin.add_logging_annotation: if true, the outermost span in this service will have an annotation set when py-zipkin begins its logging. zipkin.report_root_timestamp: if true, the outermost span in this service will set its timestamp and duration attributes. Use this only if this service is not going to have a corresponding client span. See https://github.com/Yelp/pyramid_zipkin/issues/68 zipkin.firehose_handler: [EXPERIMENTAL] this enables "firehose tracing", which will log 100% of the spans to this handler, regardless of sampling decision. This is experimental and may change or be removed at any time without warning. zipkin.use_pattern_as_span_name: if true, we'll use the pyramid route pattern as span name. If false (default) we'll keep using the raw url path.
[ "Extracts", "Zipkin", "attributes", "and", "configuration", "from", "request", "attributes", ".", "See", "the", "zipkin_span", "context", "in", "py", "-", "zipkin", "for", "more", "detaied", "information", "on", "all", "the", "settings", "." ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/tween.py#L48-L140
train
42,861
Yelp/pyramid_zipkin
pyramid_zipkin/tween.py
zipkin_tween
def zipkin_tween(handler, registry): """ Factory for pyramid tween to handle zipkin server logging. Note that even if the request isn't sampled, Zipkin attributes are generated and pushed into threadlocal storage, so `create_http_headers_for_new_span` and `zipkin_span` will have access to the proper Zipkin state. Consumes custom create_zipkin_attr function if one is set in the pyramid registry. :param handler: pyramid request handler :param registry: pyramid app registry :returns: pyramid tween """ def tween(request): zipkin_settings = _get_settings_from_request(request) tracer = get_default_tracer() tween_kwargs = dict( service_name=zipkin_settings.service_name, span_name=zipkin_settings.span_name, zipkin_attrs=zipkin_settings.zipkin_attrs, transport_handler=zipkin_settings.transport_handler, host=zipkin_settings.host, port=zipkin_settings.port, add_logging_annotation=zipkin_settings.add_logging_annotation, report_root_timestamp=zipkin_settings.report_root_timestamp, context_stack=zipkin_settings.context_stack, max_span_batch_size=zipkin_settings.max_span_batch_size, encoding=zipkin_settings.encoding, kind=Kind.SERVER, ) if zipkin_settings.firehose_handler is not None: tween_kwargs['firehose_handler'] = zipkin_settings.firehose_handler with tracer.zipkin_span(**tween_kwargs) as zipkin_context: response = handler(request) if zipkin_settings.use_pattern_as_span_name and request.matched_route: zipkin_context.override_span_name('{} {}'.format( request.method, request.matched_route.pattern, )) zipkin_context.update_binary_annotations( get_binary_annotations(request, response), ) if zipkin_settings.post_handler_hook: zipkin_settings.post_handler_hook(request, response) return response return tween
python
def zipkin_tween(handler, registry): """ Factory for pyramid tween to handle zipkin server logging. Note that even if the request isn't sampled, Zipkin attributes are generated and pushed into threadlocal storage, so `create_http_headers_for_new_span` and `zipkin_span` will have access to the proper Zipkin state. Consumes custom create_zipkin_attr function if one is set in the pyramid registry. :param handler: pyramid request handler :param registry: pyramid app registry :returns: pyramid tween """ def tween(request): zipkin_settings = _get_settings_from_request(request) tracer = get_default_tracer() tween_kwargs = dict( service_name=zipkin_settings.service_name, span_name=zipkin_settings.span_name, zipkin_attrs=zipkin_settings.zipkin_attrs, transport_handler=zipkin_settings.transport_handler, host=zipkin_settings.host, port=zipkin_settings.port, add_logging_annotation=zipkin_settings.add_logging_annotation, report_root_timestamp=zipkin_settings.report_root_timestamp, context_stack=zipkin_settings.context_stack, max_span_batch_size=zipkin_settings.max_span_batch_size, encoding=zipkin_settings.encoding, kind=Kind.SERVER, ) if zipkin_settings.firehose_handler is not None: tween_kwargs['firehose_handler'] = zipkin_settings.firehose_handler with tracer.zipkin_span(**tween_kwargs) as zipkin_context: response = handler(request) if zipkin_settings.use_pattern_as_span_name and request.matched_route: zipkin_context.override_span_name('{} {}'.format( request.method, request.matched_route.pattern, )) zipkin_context.update_binary_annotations( get_binary_annotations(request, response), ) if zipkin_settings.post_handler_hook: zipkin_settings.post_handler_hook(request, response) return response return tween
[ "def", "zipkin_tween", "(", "handler", ",", "registry", ")", ":", "def", "tween", "(", "request", ")", ":", "zipkin_settings", "=", "_get_settings_from_request", "(", "request", ")", "tracer", "=", "get_default_tracer", "(", ")", "tween_kwargs", "=", "dict", "...
Factory for pyramid tween to handle zipkin server logging. Note that even if the request isn't sampled, Zipkin attributes are generated and pushed into threadlocal storage, so `create_http_headers_for_new_span` and `zipkin_span` will have access to the proper Zipkin state. Consumes custom create_zipkin_attr function if one is set in the pyramid registry. :param handler: pyramid request handler :param registry: pyramid app registry :returns: pyramid tween
[ "Factory", "for", "pyramid", "tween", "to", "handle", "zipkin", "server", "logging", ".", "Note", "that", "even", "if", "the", "request", "isn", "t", "sampled", "Zipkin", "attributes", "are", "generated", "and", "pushed", "into", "threadlocal", "storage", "so"...
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/tween.py#L143-L196
train
42,862
MycroftAI/mycroft-skills-manager
msm/skill_repo.py
SkillRepo.get_skill_data
def get_skill_data(self): """ generates tuples of name, path, url, sha """ path_to_sha = { folder: sha for folder, sha in self.get_shas() } modules = self.read_file('.gitmodules').split('[submodule "') for i, module in enumerate(modules): if not module: continue try: name = module.split('"]')[0].strip() path = module.split('path = ')[1].split('\n')[0].strip() url = module.split('url = ')[1].strip() sha = path_to_sha.get(path, '') yield name, path, url, sha except (ValueError, IndexError) as e: LOG.warning('Failed to parse submodule "{}" #{}:{}'.format( locals().get('name', ''), i, e ))
python
def get_skill_data(self): """ generates tuples of name, path, url, sha """ path_to_sha = { folder: sha for folder, sha in self.get_shas() } modules = self.read_file('.gitmodules').split('[submodule "') for i, module in enumerate(modules): if not module: continue try: name = module.split('"]')[0].strip() path = module.split('path = ')[1].split('\n')[0].strip() url = module.split('url = ')[1].strip() sha = path_to_sha.get(path, '') yield name, path, url, sha except (ValueError, IndexError) as e: LOG.warning('Failed to parse submodule "{}" #{}:{}'.format( locals().get('name', ''), i, e ))
[ "def", "get_skill_data", "(", "self", ")", ":", "path_to_sha", "=", "{", "folder", ":", "sha", "for", "folder", ",", "sha", "in", "self", ".", "get_shas", "(", ")", "}", "modules", "=", "self", ".", "read_file", "(", "'.gitmodules'", ")", ".", "split",...
generates tuples of name, path, url, sha
[ "generates", "tuples", "of", "name", "path", "url", "sha" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/skill_repo.py#L95-L113
train
42,863
twisted/vertex
vertex/tcpdfa.py
TCP.expectAck
def expectAck(self): """ When the most recent packet produced as an output of this state machine is acknowledged by our peer, generate a single 'ack' input. """ last = self.lastTransmitted self.ackPredicate = lambda ackPacket: ( ackPacket.relativeAck() >= last.relativeSeq() )
python
def expectAck(self): """ When the most recent packet produced as an output of this state machine is acknowledged by our peer, generate a single 'ack' input. """ last = self.lastTransmitted self.ackPredicate = lambda ackPacket: ( ackPacket.relativeAck() >= last.relativeSeq() )
[ "def", "expectAck", "(", "self", ")", ":", "last", "=", "self", ".", "lastTransmitted", "self", ".", "ackPredicate", "=", "lambda", "ackPacket", ":", "(", "ackPacket", ".", "relativeAck", "(", ")", ">=", "last", ".", "relativeSeq", "(", ")", ")" ]
When the most recent packet produced as an output of this state machine is acknowledged by our peer, generate a single 'ack' input.
[ "When", "the", "most", "recent", "packet", "produced", "as", "an", "output", "of", "this", "state", "machine", "is", "acknowledged", "by", "our", "peer", "generate", "a", "single", "ack", "input", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/tcpdfa.py#L172-L180
train
42,864
dave-shawley/setupext-janitor
setupext/janitor.py
_set_options
def _set_options(): """ Set the options for CleanCommand. There are a number of reasons that this has to be done in an external function instead of inline in the class. First of all, the setuptools machinery really wants the options to be defined in a class attribute - otherwise, the help command doesn't work so we need a class attribute. However, we are extending an existing command and do not want to "monkey patch" over it so we need to define a *new* class attribute with the same name that contains a copy of the base class value. This could be accomplished using some magic in ``__new__`` but I would much rather set the class attribute externally... it's just cleaner. """ CleanCommand.user_options = _CleanCommand.user_options[:] CleanCommand.user_options.extend([ ('dist', 'd', 'remove distribution directory'), ('eggs', None, 'remove egg and egg-info directories'), ('environment', 'E', 'remove virtual environment directory'), ('pycache', 'p', 'remove __pycache__ directories'), ('egg-base=', 'e', 'directory containing .egg-info directories ' '(default: top of the source tree)'), ('virtualenv-dir=', None, 'root directory for the virtual directory ' '(default: value of VIRTUAL_ENV environment variable)'), ]) CleanCommand.boolean_options = _CleanCommand.boolean_options[:] CleanCommand.boolean_options.extend( ['dist', 'eggs', 'environment', 'pycache'])
python
def _set_options(): """ Set the options for CleanCommand. There are a number of reasons that this has to be done in an external function instead of inline in the class. First of all, the setuptools machinery really wants the options to be defined in a class attribute - otherwise, the help command doesn't work so we need a class attribute. However, we are extending an existing command and do not want to "monkey patch" over it so we need to define a *new* class attribute with the same name that contains a copy of the base class value. This could be accomplished using some magic in ``__new__`` but I would much rather set the class attribute externally... it's just cleaner. """ CleanCommand.user_options = _CleanCommand.user_options[:] CleanCommand.user_options.extend([ ('dist', 'd', 'remove distribution directory'), ('eggs', None, 'remove egg and egg-info directories'), ('environment', 'E', 'remove virtual environment directory'), ('pycache', 'p', 'remove __pycache__ directories'), ('egg-base=', 'e', 'directory containing .egg-info directories ' '(default: top of the source tree)'), ('virtualenv-dir=', None, 'root directory for the virtual directory ' '(default: value of VIRTUAL_ENV environment variable)'), ]) CleanCommand.boolean_options = _CleanCommand.boolean_options[:] CleanCommand.boolean_options.extend( ['dist', 'eggs', 'environment', 'pycache'])
[ "def", "_set_options", "(", ")", ":", "CleanCommand", ".", "user_options", "=", "_CleanCommand", ".", "user_options", "[", ":", "]", "CleanCommand", ".", "user_options", ".", "extend", "(", "[", "(", "'dist'", ",", "'d'", ",", "'remove distribution directory'", ...
Set the options for CleanCommand. There are a number of reasons that this has to be done in an external function instead of inline in the class. First of all, the setuptools machinery really wants the options to be defined in a class attribute - otherwise, the help command doesn't work so we need a class attribute. However, we are extending an existing command and do not want to "monkey patch" over it so we need to define a *new* class attribute with the same name that contains a copy of the base class value. This could be accomplished using some magic in ``__new__`` but I would much rather set the class attribute externally... it's just cleaner.
[ "Set", "the", "options", "for", "CleanCommand", "." ]
801d4e51b10c8880be16c99fd6316051808141fa
https://github.com/dave-shawley/setupext-janitor/blob/801d4e51b10c8880be16c99fd6316051808141fa/setupext/janitor.py#L102-L134
train
42,865
twisted/vertex
vertex/sigma.py
openMaskFile
def openMaskFile(filename): """ Open the bitmask file sitting next to a file in the filesystem. """ dirname, basename = os.path.split(filename) newbasename = '_%s_.sbm' % (basename,) maskfname = os.path.join(dirname, newbasename) maskfile = openReadWrite(maskfname) return maskfile
python
def openMaskFile(filename): """ Open the bitmask file sitting next to a file in the filesystem. """ dirname, basename = os.path.split(filename) newbasename = '_%s_.sbm' % (basename,) maskfname = os.path.join(dirname, newbasename) maskfile = openReadWrite(maskfname) return maskfile
[ "def", "openMaskFile", "(", "filename", ")", ":", "dirname", ",", "basename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "newbasename", "=", "'_%s_.sbm'", "%", "(", "basename", ",", ")", "maskfname", "=", "os", ".", "path", ".", "join"...
Open the bitmask file sitting next to a file in the filesystem.
[ "Open", "the", "bitmask", "file", "sitting", "next", "to", "a", "file", "in", "the", "filesystem", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L599-L607
train
42,866
twisted/vertex
vertex/sigma.py
SigmaProtocol.data
def data(self, name, chunk, body): """ Issue a DATA command return None Sends a chunk of data to a peer. """ self.callRemote(Data, name=name, chunk=chunk, body=body)
python
def data(self, name, chunk, body): """ Issue a DATA command return None Sends a chunk of data to a peer. """ self.callRemote(Data, name=name, chunk=chunk, body=body)
[ "def", "data", "(", "self", ",", "name", ",", "chunk", ",", "body", ")", ":", "self", ".", "callRemote", "(", "Data", ",", "name", "=", "name", ",", "chunk", "=", "chunk", ",", "body", "=", "body", ")" ]
Issue a DATA command return None Sends a chunk of data to a peer.
[ "Issue", "a", "DATA", "command" ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L168-L176
train
42,867
twisted/vertex
vertex/sigma.py
SigmaProtocol.get
def get(self, name, mask=None): """ Issue a GET command Return a Deferred which fires with the size of the name being requested """ mypeer = self.transport.getQ2QPeer() tl = self.nexus.transloads[name] peerz = tl.peers if mypeer in peerz: peerk = peerz[mypeer] else: # all turned on initially; we aren't going to send them anything. peerk = PeerKnowledge(bits.BitArray(size=len(tl.mask), default=1)) peerz[mypeer] = peerk peerk.sentGet = True return self.callRemote( Get, name=name, mask=mask).addCallback(lambda r: r['size'])
python
def get(self, name, mask=None): """ Issue a GET command Return a Deferred which fires with the size of the name being requested """ mypeer = self.transport.getQ2QPeer() tl = self.nexus.transloads[name] peerz = tl.peers if mypeer in peerz: peerk = peerz[mypeer] else: # all turned on initially; we aren't going to send them anything. peerk = PeerKnowledge(bits.BitArray(size=len(tl.mask), default=1)) peerz[mypeer] = peerk peerk.sentGet = True return self.callRemote( Get, name=name, mask=mask).addCallback(lambda r: r['size'])
[ "def", "get", "(", "self", ",", "name", ",", "mask", "=", "None", ")", ":", "mypeer", "=", "self", ".", "transport", ".", "getQ2QPeer", "(", ")", "tl", "=", "self", ".", "nexus", ".", "transloads", "[", "name", "]", "peerz", "=", "tl", ".", "peer...
Issue a GET command Return a Deferred which fires with the size of the name being requested
[ "Issue", "a", "GET", "command" ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L204-L221
train
42,868
twisted/vertex
vertex/sigma.py
PeerKnowledge.selectPeerToIntroduce
def selectPeerToIntroduce(self, otherPeers): """ Choose a peer to introduce. Return a q2q address or None, if there are no suitable peers to introduce at this time. """ for peer in otherPeers: if peer not in self.otherPeers: self.otherPeers.append(peer) return peer
python
def selectPeerToIntroduce(self, otherPeers): """ Choose a peer to introduce. Return a q2q address or None, if there are no suitable peers to introduce at this time. """ for peer in otherPeers: if peer not in self.otherPeers: self.otherPeers.append(peer) return peer
[ "def", "selectPeerToIntroduce", "(", "self", ",", "otherPeers", ")", ":", "for", "peer", "in", "otherPeers", ":", "if", "peer", "not", "in", "self", ".", "otherPeers", ":", "self", ".", "otherPeers", ".", "append", "(", "peer", ")", "return", "peer" ]
Choose a peer to introduce. Return a q2q address or None, if there are no suitable peers to introduce at this time.
[ "Choose", "a", "peer", "to", "introduce", ".", "Return", "a", "q2q", "address", "or", "None", "if", "there", "are", "no", "suitable", "peers", "to", "introduce", "at", "this", "time", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L344-L352
train
42,869
twisted/vertex
vertex/sigma.py
Transload.chunkReceived
def chunkReceived(self, who, chunkNumber, chunkData): """ A chunk was received from the peer. """ def verifyError(error): error.trap(VerifyError) self.nexus.decreaseScore(who, self.authorities) return self.nexus.verifyChunk(self.name, who, chunkNumber, sha.new(chunkData).digest(), self.authorities).addCallbacks( lambda whatever: self.chunkVerified(who, chunkNumber, chunkData), verifyError)
python
def chunkReceived(self, who, chunkNumber, chunkData): """ A chunk was received from the peer. """ def verifyError(error): error.trap(VerifyError) self.nexus.decreaseScore(who, self.authorities) return self.nexus.verifyChunk(self.name, who, chunkNumber, sha.new(chunkData).digest(), self.authorities).addCallbacks( lambda whatever: self.chunkVerified(who, chunkNumber, chunkData), verifyError)
[ "def", "chunkReceived", "(", "self", ",", "who", ",", "chunkNumber", ",", "chunkData", ")", ":", "def", "verifyError", "(", "error", ")", ":", "error", ".", "trap", "(", "VerifyError", ")", "self", ".", "nexus", ".", "decreaseScore", "(", "who", ",", "...
A chunk was received from the peer.
[ "A", "chunk", "was", "received", "from", "the", "peer", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L458-L471
train
42,870
twisted/vertex
vertex/sigma.py
Transload.selectOptimalChunk
def selectOptimalChunk(self, peer): """ select an optimal chunk to send to a peer. @return: int(chunkNumber), str(chunkData) if there is data to be sent, otherwise None, None """ # stuff I have have = sets.Set(self.mask.positions(1)) # stuff that this peer wants want = sets.Set(self.peers[peer].mask.positions(0)) exchangeable = have.intersection(want) finalSet = dict.fromkeys(exchangeable, 0) # taking a page from bittorrent, rarest-first for chunkNumber in exchangeable: for otherPeer in self.peers.itervalues(): finalSet[chunkNumber] += not otherPeer.mask[chunkNumber] rarityList = [(rarity, random.random(), chunkNumber) for (chunkNumber, rarity) in finalSet.iteritems()] if not rarityList: return None, None rarityList.sort() chunkNumber = rarityList[-1][-1] # sorted in ascending order of rarity # sanity check assert self.mask[chunkNumber], "I wanted to send a chunk I didn't have" self.file.seek(chunkNumber * CHUNK_SIZE) chunkData = self.file.read(CHUNK_SIZE) self.sha1sums[chunkNumber] = sha.new(chunkData).digest() return chunkNumber, chunkData
python
def selectOptimalChunk(self, peer): """ select an optimal chunk to send to a peer. @return: int(chunkNumber), str(chunkData) if there is data to be sent, otherwise None, None """ # stuff I have have = sets.Set(self.mask.positions(1)) # stuff that this peer wants want = sets.Set(self.peers[peer].mask.positions(0)) exchangeable = have.intersection(want) finalSet = dict.fromkeys(exchangeable, 0) # taking a page from bittorrent, rarest-first for chunkNumber in exchangeable: for otherPeer in self.peers.itervalues(): finalSet[chunkNumber] += not otherPeer.mask[chunkNumber] rarityList = [(rarity, random.random(), chunkNumber) for (chunkNumber, rarity) in finalSet.iteritems()] if not rarityList: return None, None rarityList.sort() chunkNumber = rarityList[-1][-1] # sorted in ascending order of rarity # sanity check assert self.mask[chunkNumber], "I wanted to send a chunk I didn't have" self.file.seek(chunkNumber * CHUNK_SIZE) chunkData = self.file.read(CHUNK_SIZE) self.sha1sums[chunkNumber] = sha.new(chunkData).digest() return chunkNumber, chunkData
[ "def", "selectOptimalChunk", "(", "self", ",", "peer", ")", ":", "# stuff I have", "have", "=", "sets", ".", "Set", "(", "self", ".", "mask", ".", "positions", "(", "1", ")", ")", "# stuff that this peer wants", "want", "=", "sets", ".", "Set", "(", "sel...
select an optimal chunk to send to a peer. @return: int(chunkNumber), str(chunkData) if there is data to be sent, otherwise None, None
[ "select", "an", "optimal", "chunk", "to", "send", "to", "a", "peer", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L518-L551
train
42,871
twisted/vertex
vertex/sigma.py
BaseNexusUI.allocateFile
def allocateFile(self, sharename, peer): """ return a 2-tuple of incompletePath, fullPath """ peerDir = self.basepath.child(str(peer)) if not peerDir.isdir(): peerDir.makedirs() return (peerDir.child(sharename+'.incomplete'), peerDir.child(sharename))
python
def allocateFile(self, sharename, peer): """ return a 2-tuple of incompletePath, fullPath """ peerDir = self.basepath.child(str(peer)) if not peerDir.isdir(): peerDir.makedirs() return (peerDir.child(sharename+'.incomplete'), peerDir.child(sharename))
[ "def", "allocateFile", "(", "self", ",", "sharename", ",", "peer", ")", ":", "peerDir", "=", "self", ".", "basepath", ".", "child", "(", "str", "(", "peer", ")", ")", "if", "not", "peerDir", ".", "isdir", "(", ")", ":", "peerDir", ".", "makedirs", ...
return a 2-tuple of incompletePath, fullPath
[ "return", "a", "2", "-", "tuple", "of", "incompletePath", "fullPath" ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L646-L654
train
42,872
twisted/vertex
vertex/sigma.py
Nexus.transloadsForPeer
def transloadsForPeer(self, peer): """ Returns an iterator of transloads that apply to a particular peer. """ for tl in self.transloads.itervalues(): if peer in tl.peers: yield tl
python
def transloadsForPeer(self, peer): """ Returns an iterator of transloads that apply to a particular peer. """ for tl in self.transloads.itervalues(): if peer in tl.peers: yield tl
[ "def", "transloadsForPeer", "(", "self", ",", "peer", ")", ":", "for", "tl", "in", "self", ".", "transloads", ".", "itervalues", "(", ")", ":", "if", "peer", "in", "tl", ".", "peers", ":", "yield", "tl" ]
Returns an iterator of transloads that apply to a particular peer.
[ "Returns", "an", "iterator", "of", "transloads", "that", "apply", "to", "a", "particular", "peer", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L705-L711
train
42,873
twisted/vertex
vertex/sigma.py
Nexus.seed
def seed(self, path, name): """Create a transload from an existing file that is complete. """ t = self.transloads[name] = Transload(self.addr, self, name, None, path, self.ui.startTransload(name, self.addr), seed=True) return t
python
def seed(self, path, name): """Create a transload from an existing file that is complete. """ t = self.transloads[name] = Transload(self.addr, self, name, None, path, self.ui.startTransload(name, self.addr), seed=True) return t
[ "def", "seed", "(", "self", ",", "path", ",", "name", ")", ":", "t", "=", "self", ".", "transloads", "[", "name", "]", "=", "Transload", "(", "self", ".", "addr", ",", "self", ",", "name", ",", "None", ",", "path", ",", "self", ".", "ui", ".", ...
Create a transload from an existing file that is complete.
[ "Create", "a", "transload", "from", "an", "existing", "file", "that", "is", "complete", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L713-L721
train
42,874
twisted/vertex
vertex/sigma.py
Nexus.connectPeer
def connectPeer(self, peer): """Establish a SIGMA connection to the given peer. @param peer: a Q2QAddress of a peer which has a file that I want @return: a Deferred which fires a SigmaProtocol. """ return self.conns.connectCached(endpoint.Q2QEndpoint(self.svc, self.addr, peer, PROTOCOL_NAME), self.clientFactory)
python
def connectPeer(self, peer): """Establish a SIGMA connection to the given peer. @param peer: a Q2QAddress of a peer which has a file that I want @return: a Deferred which fires a SigmaProtocol. """ return self.conns.connectCached(endpoint.Q2QEndpoint(self.svc, self.addr, peer, PROTOCOL_NAME), self.clientFactory)
[ "def", "connectPeer", "(", "self", ",", "peer", ")", ":", "return", "self", ".", "conns", ".", "connectCached", "(", "endpoint", ".", "Q2QEndpoint", "(", "self", ".", "svc", ",", "self", ".", "addr", ",", "peer", ",", "PROTOCOL_NAME", ")", ",", "self",...
Establish a SIGMA connection to the given peer. @param peer: a Q2QAddress of a peer which has a file that I want @return: a Deferred which fires a SigmaProtocol.
[ "Establish", "a", "SIGMA", "connection", "to", "the", "given", "peer", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L723-L734
train
42,875
twisted/vertex
vertex/sigma.py
Nexus.increaseScore
def increaseScore(self, participant): """ The participant successfully transferred a chunk to me. """ if participant not in self.scores: self.scores[participant] = 0 self.scores[participant] += 1
python
def increaseScore(self, participant): """ The participant successfully transferred a chunk to me. """ if participant not in self.scores: self.scores[participant] = 0 self.scores[participant] += 1
[ "def", "increaseScore", "(", "self", ",", "participant", ")", ":", "if", "participant", "not", "in", "self", ".", "scores", ":", "self", ".", "scores", "[", "participant", "]", "=", "0", "self", ".", "scores", "[", "participant", "]", "+=", "1" ]
The participant successfully transferred a chunk to me.
[ "The", "participant", "successfully", "transferred", "a", "chunk", "to", "me", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L749-L755
train
42,876
Hundemeier/sacn
sacn/receiver.py
sACNreceiver.start
def start(self) -> None: """ Starts a new thread that handles the input. If a thread is already running, the thread will be restarted. """ self.stop() # stop an existing thread self._thread = receiverThread(socket=self.sock, callbacks=self._callbacks) self._thread.start()
python
def start(self) -> None: """ Starts a new thread that handles the input. If a thread is already running, the thread will be restarted. """ self.stop() # stop an existing thread self._thread = receiverThread(socket=self.sock, callbacks=self._callbacks) self._thread.start()
[ "def", "start", "(", "self", ")", "->", "None", ":", "self", ".", "stop", "(", ")", "# stop an existing thread", "self", ".", "_thread", "=", "receiverThread", "(", "socket", "=", "self", ".", "sock", ",", "callbacks", "=", "self", ".", "_callbacks", ")"...
Starts a new thread that handles the input. If a thread is already running, the thread will be restarted.
[ "Starts", "a", "new", "thread", "that", "handles", "the", "input", ".", "If", "a", "thread", "is", "already", "running", "the", "thread", "will", "be", "restarted", "." ]
f08bf3d7554a1ed2870f23a9e0e7b89a4a509231
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/receiver.py#L94-L100
train
42,877
mikeboers/Flask-ACL
flask_acl/extension.py
ACLManager.route_acl
def route_acl(self, *acl, **options): """Decorator to attach an ACL to a route. E.g:: @app.route('/url/to/view') @authz.route_acl(''' ALLOW WHEEL ALL DENY ANY ALL ''') def my_admin_function(): pass """ def _route_acl(func): func.__acl__ = acl @functools.wraps(func) def wrapped(*args, **kwargs): permission = 'http.' + request.method.lower() local_opts = options.copy() local_opts.setdefault('default', current_app.config['ACL_ROUTE_DEFAULT_STATE']) self.assert_can(permission, func, **local_opts) return func(*args, **kwargs) return wrapped return _route_acl
python
def route_acl(self, *acl, **options): """Decorator to attach an ACL to a route. E.g:: @app.route('/url/to/view') @authz.route_acl(''' ALLOW WHEEL ALL DENY ANY ALL ''') def my_admin_function(): pass """ def _route_acl(func): func.__acl__ = acl @functools.wraps(func) def wrapped(*args, **kwargs): permission = 'http.' + request.method.lower() local_opts = options.copy() local_opts.setdefault('default', current_app.config['ACL_ROUTE_DEFAULT_STATE']) self.assert_can(permission, func, **local_opts) return func(*args, **kwargs) return wrapped return _route_acl
[ "def", "route_acl", "(", "self", ",", "*", "acl", ",", "*", "*", "options", ")", ":", "def", "_route_acl", "(", "func", ")", ":", "func", ".", "__acl__", "=", "acl", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapped", "(", "*", "a...
Decorator to attach an ACL to a route. E.g:: @app.route('/url/to/view') @authz.route_acl(''' ALLOW WHEEL ALL DENY ANY ALL ''') def my_admin_function(): pass
[ "Decorator", "to", "attach", "an", "ACL", "to", "a", "route", "." ]
7339b89f96ad8686d1526e25c138244ad912e12d
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/extension.py#L116-L144
train
42,878
mikeboers/Flask-ACL
flask_acl/extension.py
ACLManager.can
def can(self, permission, obj, **kwargs): """Check if we can do something with an object. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param **kwargs: The context to pass to predicates. >>> auth.can('read', some_object) >>> auth.can('write', another_object, group=some_group) """ context = {'user': current_user} for func in self.context_processors: context.update(func()) context.update(get_object_context(obj)) context.update(kwargs) return check(permission, iter_object_acl(obj), **context)
python
def can(self, permission, obj, **kwargs): """Check if we can do something with an object. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param **kwargs: The context to pass to predicates. >>> auth.can('read', some_object) >>> auth.can('write', another_object, group=some_group) """ context = {'user': current_user} for func in self.context_processors: context.update(func()) context.update(get_object_context(obj)) context.update(kwargs) return check(permission, iter_object_acl(obj), **context)
[ "def", "can", "(", "self", ",", "permission", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "context", "=", "{", "'user'", ":", "current_user", "}", "for", "func", "in", "self", ".", "context_processors", ":", "context", ".", "update", "(", "func", ...
Check if we can do something with an object. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param **kwargs: The context to pass to predicates. >>> auth.can('read', some_object) >>> auth.can('write', another_object, group=some_group)
[ "Check", "if", "we", "can", "do", "something", "with", "an", "object", "." ]
7339b89f96ad8686d1526e25c138244ad912e12d
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/extension.py#L146-L163
train
42,879
mikeboers/Flask-ACL
flask_acl/extension.py
ACLManager.assert_can
def assert_can(self, permission, obj, **kwargs): """Make sure we have a permission, or abort the request. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param flash: The message to flask if denied (keyword only). :param stealth: Abort with a 404? (keyword only). :param **kwargs: The context to pass to predicates. """ flash_message = kwargs.pop('flash', None) stealth = kwargs.pop('stealth', False) default = kwargs.pop('default', None) res = self.can(permission, obj, **kwargs) res = default if res is None else res if not res: if flash_message and not stealth: flask.flash(flash_message, 'danger') if current_user.is_authenticated(): if flash_message is not False: flask.flash(flash_message or 'You are not permitted to "%s" this resource' % permission) flask.abort(403) elif not stealth and self.login_view: if flash_message is not False: flask.flash(flash_message or 'Please login for access.') raise _Redirect(flask.url_for(self.login_view) + '?' + urlencode(dict(next= flask.request.script_root + flask.request.path ))) else: flask.abort(404)
python
def assert_can(self, permission, obj, **kwargs): """Make sure we have a permission, or abort the request. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param flash: The message to flask if denied (keyword only). :param stealth: Abort with a 404? (keyword only). :param **kwargs: The context to pass to predicates. """ flash_message = kwargs.pop('flash', None) stealth = kwargs.pop('stealth', False) default = kwargs.pop('default', None) res = self.can(permission, obj, **kwargs) res = default if res is None else res if not res: if flash_message and not stealth: flask.flash(flash_message, 'danger') if current_user.is_authenticated(): if flash_message is not False: flask.flash(flash_message or 'You are not permitted to "%s" this resource' % permission) flask.abort(403) elif not stealth and self.login_view: if flash_message is not False: flask.flash(flash_message or 'Please login for access.') raise _Redirect(flask.url_for(self.login_view) + '?' + urlencode(dict(next= flask.request.script_root + flask.request.path ))) else: flask.abort(404)
[ "def", "assert_can", "(", "self", ",", "permission", ",", "obj", ",", "*", "*", "kwargs", ")", ":", "flash_message", "=", "kwargs", ".", "pop", "(", "'flash'", ",", "None", ")", "stealth", "=", "kwargs", ".", "pop", "(", "'stealth'", ",", "False", ")...
Make sure we have a permission, or abort the request. :param permission: The permission to look for. :param obj: The object to check the ACL of. :param flash: The message to flask if denied (keyword only). :param stealth: Abort with a 404? (keyword only). :param **kwargs: The context to pass to predicates.
[ "Make", "sure", "we", "have", "a", "permission", "or", "abort", "the", "request", "." ]
7339b89f96ad8686d1526e25c138244ad912e12d
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/extension.py#L165-L196
train
42,880
mikeboers/Flask-ACL
flask_acl/extension.py
ACLManager.can_route
def can_route(self, endpoint, method=None, **kwargs): """Make sure we can route to the given endpoint or url. This checks for `http.get` permission (or other methods) on the ACL of route functions, attached via the `ACL` decorator. :param endpoint: A URL or endpoint to check for permission to access. :param method: The HTTP method to check; defaults to `'GET'`. :param **kwargs: The context to pass to predicates. """ view = flask.current_app.view_functions.get(endpoint) if not view: endpoint, args = flask._request_ctx.top.match(endpoint) view = flask.current_app.view_functions.get(endpoint) if not view: return False return self.can('http.' + (method or 'GET').lower(), view, **kwargs)
python
def can_route(self, endpoint, method=None, **kwargs): """Make sure we can route to the given endpoint or url. This checks for `http.get` permission (or other methods) on the ACL of route functions, attached via the `ACL` decorator. :param endpoint: A URL or endpoint to check for permission to access. :param method: The HTTP method to check; defaults to `'GET'`. :param **kwargs: The context to pass to predicates. """ view = flask.current_app.view_functions.get(endpoint) if not view: endpoint, args = flask._request_ctx.top.match(endpoint) view = flask.current_app.view_functions.get(endpoint) if not view: return False return self.can('http.' + (method or 'GET').lower(), view, **kwargs)
[ "def", "can_route", "(", "self", ",", "endpoint", ",", "method", "=", "None", ",", "*", "*", "kwargs", ")", ":", "view", "=", "flask", ".", "current_app", ".", "view_functions", ".", "get", "(", "endpoint", ")", "if", "not", "view", ":", "endpoint", ...
Make sure we can route to the given endpoint or url. This checks for `http.get` permission (or other methods) on the ACL of route functions, attached via the `ACL` decorator. :param endpoint: A URL or endpoint to check for permission to access. :param method: The HTTP method to check; defaults to `'GET'`. :param **kwargs: The context to pass to predicates.
[ "Make", "sure", "we", "can", "route", "to", "the", "given", "endpoint", "or", "url", "." ]
7339b89f96ad8686d1526e25c138244ad912e12d
https://github.com/mikeboers/Flask-ACL/blob/7339b89f96ad8686d1526e25c138244ad912e12d/flask_acl/extension.py#L198-L217
train
42,881
Yelp/pyramid_zipkin
pyramid_zipkin/request_helper.py
should_not_sample_path
def should_not_sample_path(request): """Decided whether current request path should be sampled or not. This is checked previous to `should_not_sample_route` and takes precedence. :param: current active pyramid request :returns: boolean whether current request path is blacklisted. """ blacklisted_paths = request.registry.settings.get( 'zipkin.blacklisted_paths', []) # Only compile strings, since even recompiling existing # compiled regexes takes time. regexes = [ re.compile(r) if isinstance(r, six.string_types) else r for r in blacklisted_paths ] return any(r.match(request.path) for r in regexes)
python
def should_not_sample_path(request): """Decided whether current request path should be sampled or not. This is checked previous to `should_not_sample_route` and takes precedence. :param: current active pyramid request :returns: boolean whether current request path is blacklisted. """ blacklisted_paths = request.registry.settings.get( 'zipkin.blacklisted_paths', []) # Only compile strings, since even recompiling existing # compiled regexes takes time. regexes = [ re.compile(r) if isinstance(r, six.string_types) else r for r in blacklisted_paths ] return any(r.match(request.path) for r in regexes)
[ "def", "should_not_sample_path", "(", "request", ")", ":", "blacklisted_paths", "=", "request", ".", "registry", ".", "settings", ".", "get", "(", "'zipkin.blacklisted_paths'", ",", "[", "]", ")", "# Only compile strings, since even recompiling existing", "# compiled rege...
Decided whether current request path should be sampled or not. This is checked previous to `should_not_sample_route` and takes precedence. :param: current active pyramid request :returns: boolean whether current request path is blacklisted.
[ "Decided", "whether", "current", "request", "path", "should", "be", "sampled", "or", "not", ".", "This", "is", "checked", "previous", "to", "should_not_sample_route", "and", "takes", "precedence", "." ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/request_helper.py#L49-L64
train
42,882
Yelp/pyramid_zipkin
pyramid_zipkin/request_helper.py
should_not_sample_route
def should_not_sample_route(request): """Decided whether current request route should be sampled or not. :param: current active pyramid request :returns: boolean whether current request route is blacklisted. """ blacklisted_routes = request.registry.settings.get( 'zipkin.blacklisted_routes', []) if not blacklisted_routes: return False route_mapper = request.registry.queryUtility(IRoutesMapper) route_info = route_mapper(request).get('route') return (route_info and route_info.name in blacklisted_routes)
python
def should_not_sample_route(request): """Decided whether current request route should be sampled or not. :param: current active pyramid request :returns: boolean whether current request route is blacklisted. """ blacklisted_routes = request.registry.settings.get( 'zipkin.blacklisted_routes', []) if not blacklisted_routes: return False route_mapper = request.registry.queryUtility(IRoutesMapper) route_info = route_mapper(request).get('route') return (route_info and route_info.name in blacklisted_routes)
[ "def", "should_not_sample_route", "(", "request", ")", ":", "blacklisted_routes", "=", "request", ".", "registry", ".", "settings", ".", "get", "(", "'zipkin.blacklisted_routes'", ",", "[", "]", ")", "if", "not", "blacklisted_routes", ":", "return", "False", "ro...
Decided whether current request route should be sampled or not. :param: current active pyramid request :returns: boolean whether current request route is blacklisted.
[ "Decided", "whether", "current", "request", "route", "should", "be", "sampled", "or", "not", "." ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/request_helper.py#L67-L80
train
42,883
Yelp/pyramid_zipkin
pyramid_zipkin/request_helper.py
create_zipkin_attr
def create_zipkin_attr(request): """Create ZipkinAttrs object from a request with sampled flag as True. Attaches lazy attribute `zipkin_trace_id` with request which is then used throughout the tween. Consumes custom is_tracing function to determine if the request is traced if one is set in the pyramid registry. :param request: pyramid request object :rtype: :class:`pyramid_zipkin.request_helper.ZipkinAttrs` """ settings = request.registry.settings if 'zipkin.is_tracing' in settings: is_sampled = settings['zipkin.is_tracing'](request) else: is_sampled = is_tracing(request) request.zipkin_trace_id = get_trace_id(request) span_id = request.headers.get( 'X-B3-SpanId', generate_random_64bit_string()) parent_span_id = request.headers.get('X-B3-ParentSpanId', None) flags = request.headers.get('X-B3-Flags', '0') return ZipkinAttrs( trace_id=request.zipkin_trace_id, span_id=span_id, parent_span_id=parent_span_id, flags=flags, is_sampled=is_sampled, )
python
def create_zipkin_attr(request): """Create ZipkinAttrs object from a request with sampled flag as True. Attaches lazy attribute `zipkin_trace_id` with request which is then used throughout the tween. Consumes custom is_tracing function to determine if the request is traced if one is set in the pyramid registry. :param request: pyramid request object :rtype: :class:`pyramid_zipkin.request_helper.ZipkinAttrs` """ settings = request.registry.settings if 'zipkin.is_tracing' in settings: is_sampled = settings['zipkin.is_tracing'](request) else: is_sampled = is_tracing(request) request.zipkin_trace_id = get_trace_id(request) span_id = request.headers.get( 'X-B3-SpanId', generate_random_64bit_string()) parent_span_id = request.headers.get('X-B3-ParentSpanId', None) flags = request.headers.get('X-B3-Flags', '0') return ZipkinAttrs( trace_id=request.zipkin_trace_id, span_id=span_id, parent_span_id=parent_span_id, flags=flags, is_sampled=is_sampled, )
[ "def", "create_zipkin_attr", "(", "request", ")", ":", "settings", "=", "request", ".", "registry", ".", "settings", "if", "'zipkin.is_tracing'", "in", "settings", ":", "is_sampled", "=", "settings", "[", "'zipkin.is_tracing'", "]", "(", "request", ")", "else", ...
Create ZipkinAttrs object from a request with sampled flag as True. Attaches lazy attribute `zipkin_trace_id` with request which is then used throughout the tween. Consumes custom is_tracing function to determine if the request is traced if one is set in the pyramid registry. :param request: pyramid request object :rtype: :class:`pyramid_zipkin.request_helper.ZipkinAttrs`
[ "Create", "ZipkinAttrs", "object", "from", "a", "request", "with", "sampled", "flag", "as", "True", ".", "Attaches", "lazy", "attribute", "zipkin_trace_id", "with", "request", "which", "is", "then", "used", "throughout", "the", "tween", "." ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/request_helper.py#L117-L147
train
42,884
Yelp/pyramid_zipkin
pyramid_zipkin/request_helper.py
get_binary_annotations
def get_binary_annotations(request, response): """Helper method for getting all binary annotations from the request. :param request: the Pyramid request object :param response: the Pyramid response object :returns: binary annotation dict of {str: str} """ route = request.matched_route.pattern if request.matched_route else '' annotations = { 'http.uri': request.path, 'http.uri.qs': request.path_qs, 'http.route': route, 'response_status_code': str(response.status_code), } settings = request.registry.settings if 'zipkin.set_extra_binary_annotations' in settings: annotations.update( settings['zipkin.set_extra_binary_annotations'](request, response) ) return annotations
python
def get_binary_annotations(request, response): """Helper method for getting all binary annotations from the request. :param request: the Pyramid request object :param response: the Pyramid response object :returns: binary annotation dict of {str: str} """ route = request.matched_route.pattern if request.matched_route else '' annotations = { 'http.uri': request.path, 'http.uri.qs': request.path_qs, 'http.route': route, 'response_status_code': str(response.status_code), } settings = request.registry.settings if 'zipkin.set_extra_binary_annotations' in settings: annotations.update( settings['zipkin.set_extra_binary_annotations'](request, response) ) return annotations
[ "def", "get_binary_annotations", "(", "request", ",", "response", ")", ":", "route", "=", "request", ".", "matched_route", ".", "pattern", "if", "request", ".", "matched_route", "else", "''", "annotations", "=", "{", "'http.uri'", ":", "request", ".", "path", ...
Helper method for getting all binary annotations from the request. :param request: the Pyramid request object :param response: the Pyramid response object :returns: binary annotation dict of {str: str}
[ "Helper", "method", "for", "getting", "all", "binary", "annotations", "from", "the", "request", "." ]
ed8581b4466e9ce93d6cf3ecfbdde5369932a80b
https://github.com/Yelp/pyramid_zipkin/blob/ed8581b4466e9ce93d6cf3ecfbdde5369932a80b/pyramid_zipkin/request_helper.py#L150-L170
train
42,885
Hundemeier/sacn
sacn/messages/data_packet.py
DataPacket.dmxData
def dmxData(self, data: tuple): """ For legacy devices and to prevent errors, the length of the DMX data is normalized to 512 """ newData = [0]*512 for i in range(0, min(len(data), 512)): newData[i] = data[i] self._dmxData = tuple(newData) # in theory this class supports dynamic length, so the next line is correcting the length self.length = 126 + len(self._dmxData)
python
def dmxData(self, data: tuple): """ For legacy devices and to prevent errors, the length of the DMX data is normalized to 512 """ newData = [0]*512 for i in range(0, min(len(data), 512)): newData[i] = data[i] self._dmxData = tuple(newData) # in theory this class supports dynamic length, so the next line is correcting the length self.length = 126 + len(self._dmxData)
[ "def", "dmxData", "(", "self", ",", "data", ":", "tuple", ")", ":", "newData", "=", "[", "0", "]", "*", "512", "for", "i", "in", "range", "(", "0", ",", "min", "(", "len", "(", "data", ")", ",", "512", ")", ")", ":", "newData", "[", "i", "]...
For legacy devices and to prevent errors, the length of the DMX data is normalized to 512
[ "For", "legacy", "devices", "and", "to", "prevent", "errors", "the", "length", "of", "the", "DMX", "data", "is", "normalized", "to", "512" ]
f08bf3d7554a1ed2870f23a9e0e7b89a4a509231
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/messages/data_packet.py#L69-L78
train
42,886
Hundemeier/sacn
sacn/messages/root_layer.py
RootLayer.getBytes
def getBytes(self) -> list: '''Returns the Root layer as list with bytes''' tmpList = [] tmpList.extend(_FIRST_INDEX) # first append the high byte from the Flags and Length # high 4 bit: 0x7 then the bits 8-11(indexes) from _length length = self.length - 16 tmpList.append((0x7 << 4) + (length >> 8)) # Then append the lower 8 bits from _length tmpList.append(length & 0xFF) tmpList.extend(self._vector) tmpList.extend(self._cid) return tmpList
python
def getBytes(self) -> list: '''Returns the Root layer as list with bytes''' tmpList = [] tmpList.extend(_FIRST_INDEX) # first append the high byte from the Flags and Length # high 4 bit: 0x7 then the bits 8-11(indexes) from _length length = self.length - 16 tmpList.append((0x7 << 4) + (length >> 8)) # Then append the lower 8 bits from _length tmpList.append(length & 0xFF) tmpList.extend(self._vector) tmpList.extend(self._cid) return tmpList
[ "def", "getBytes", "(", "self", ")", "->", "list", ":", "tmpList", "=", "[", "]", "tmpList", ".", "extend", "(", "_FIRST_INDEX", ")", "# first append the high byte from the Flags and Length", "# high 4 bit: 0x7 then the bits 8-11(indexes) from _length", "length", "=", "se...
Returns the Root layer as list with bytes
[ "Returns", "the", "Root", "layer", "as", "list", "with", "bytes" ]
f08bf3d7554a1ed2870f23a9e0e7b89a4a509231
https://github.com/Hundemeier/sacn/blob/f08bf3d7554a1ed2870f23a9e0e7b89a4a509231/sacn/messages/root_layer.py#L33-L46
train
42,887
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.curate_skills_data
def curate_skills_data(self, skills_data): """ Sync skills_data with actual skills on disk. """ local_skills = [s for s in self.list() if s.is_local] default_skills = [s.name for s in self.list_defaults()] local_skill_names = [s.name for s in local_skills] skills_data_skills = [s['name'] for s in skills_data['skills']] # Check for skills that aren't in the list for skill in local_skills: if skill.name not in skills_data_skills: if skill.name in default_skills: origin = 'default' elif skill.url: origin = 'cli' else: origin = 'non-msm' entry = build_skill_entry(skill.name, origin, False) skills_data['skills'].append(entry) # Check for skills in the list that doesn't exist in the filesystem remove_list = [] for s in skills_data.get('skills', []): if (s['name'] not in local_skill_names and s['installation'] == 'installed'): remove_list.append(s) for skill in remove_list: skills_data['skills'].remove(skill) return skills_data
python
def curate_skills_data(self, skills_data): """ Sync skills_data with actual skills on disk. """ local_skills = [s for s in self.list() if s.is_local] default_skills = [s.name for s in self.list_defaults()] local_skill_names = [s.name for s in local_skills] skills_data_skills = [s['name'] for s in skills_data['skills']] # Check for skills that aren't in the list for skill in local_skills: if skill.name not in skills_data_skills: if skill.name in default_skills: origin = 'default' elif skill.url: origin = 'cli' else: origin = 'non-msm' entry = build_skill_entry(skill.name, origin, False) skills_data['skills'].append(entry) # Check for skills in the list that doesn't exist in the filesystem remove_list = [] for s in skills_data.get('skills', []): if (s['name'] not in local_skill_names and s['installation'] == 'installed'): remove_list.append(s) for skill in remove_list: skills_data['skills'].remove(skill) return skills_data
[ "def", "curate_skills_data", "(", "self", ",", "skills_data", ")", ":", "local_skills", "=", "[", "s", "for", "s", "in", "self", ".", "list", "(", ")", "if", "s", ".", "is_local", "]", "default_skills", "=", "[", "s", ".", "name", "for", "s", "in", ...
Sync skills_data with actual skills on disk.
[ "Sync", "skills_data", "with", "actual", "skills", "on", "disk", "." ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L118-L145
train
42,888
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.sync_skills_data
def sync_skills_data(self): """ Update internal skill_data_structure from disk. """ self.skills_data = self.load_skills_data() if 'upgraded' in self.skills_data: self.skills_data.pop('upgraded') else: self.skills_data_hash = skills_data_hash(self.skills_data)
python
def sync_skills_data(self): """ Update internal skill_data_structure from disk. """ self.skills_data = self.load_skills_data() if 'upgraded' in self.skills_data: self.skills_data.pop('upgraded') else: self.skills_data_hash = skills_data_hash(self.skills_data)
[ "def", "sync_skills_data", "(", "self", ")", ":", "self", ".", "skills_data", "=", "self", ".", "load_skills_data", "(", ")", "if", "'upgraded'", "in", "self", ".", "skills_data", ":", "self", ".", "skills_data", ".", "pop", "(", "'upgraded'", ")", "else",...
Update internal skill_data_structure from disk.
[ "Update", "internal", "skill_data_structure", "from", "disk", "." ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L155-L161
train
42,889
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.write_skills_data
def write_skills_data(self, data=None): """ Write skills data hash if it has been modified. """ data = data or self.skills_data if skills_data_hash(data) != self.skills_data_hash: write_skills_data(data) self.skills_data_hash = skills_data_hash(data)
python
def write_skills_data(self, data=None): """ Write skills data hash if it has been modified. """ data = data or self.skills_data if skills_data_hash(data) != self.skills_data_hash: write_skills_data(data) self.skills_data_hash = skills_data_hash(data)
[ "def", "write_skills_data", "(", "self", ",", "data", "=", "None", ")", ":", "data", "=", "data", "or", "self", ".", "skills_data", "if", "skills_data_hash", "(", "data", ")", "!=", "self", ".", "skills_data_hash", ":", "write_skills_data", "(", "data", ")...
Write skills data hash if it has been modified.
[ "Write", "skills", "data", "hash", "if", "it", "has", "been", "modified", "." ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L163-L168
train
42,890
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.install
def install(self, param, author=None, constraints=None, origin=''): """Install by url or name""" if isinstance(param, SkillEntry): skill = param else: skill = self.find_skill(param, author) entry = build_skill_entry(skill.name, origin, skill.is_beta) try: skill.install(constraints) entry['installed'] = time.time() entry['installation'] = 'installed' entry['status'] = 'active' entry['beta'] = skill.is_beta except AlreadyInstalled: entry = None raise except MsmException as e: entry['installation'] = 'failed' entry['status'] = 'error' entry['failure_message'] = repr(e) raise finally: # Store the entry in the list if entry: self.skills_data['skills'].append(entry)
python
def install(self, param, author=None, constraints=None, origin=''): """Install by url or name""" if isinstance(param, SkillEntry): skill = param else: skill = self.find_skill(param, author) entry = build_skill_entry(skill.name, origin, skill.is_beta) try: skill.install(constraints) entry['installed'] = time.time() entry['installation'] = 'installed' entry['status'] = 'active' entry['beta'] = skill.is_beta except AlreadyInstalled: entry = None raise except MsmException as e: entry['installation'] = 'failed' entry['status'] = 'error' entry['failure_message'] = repr(e) raise finally: # Store the entry in the list if entry: self.skills_data['skills'].append(entry)
[ "def", "install", "(", "self", ",", "param", ",", "author", "=", "None", ",", "constraints", "=", "None", ",", "origin", "=", "''", ")", ":", "if", "isinstance", "(", "param", ",", "SkillEntry", ")", ":", "skill", "=", "param", "else", ":", "skill", ...
Install by url or name
[ "Install", "by", "url", "or", "name" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L171-L195
train
42,891
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.remove
def remove(self, param, author=None): """Remove by url or name""" if isinstance(param, SkillEntry): skill = param else: skill = self.find_skill(param, author) skill.remove() skills = [s for s in self.skills_data['skills'] if s['name'] != skill.name] self.skills_data['skills'] = skills return
python
def remove(self, param, author=None): """Remove by url or name""" if isinstance(param, SkillEntry): skill = param else: skill = self.find_skill(param, author) skill.remove() skills = [s for s in self.skills_data['skills'] if s['name'] != skill.name] self.skills_data['skills'] = skills return
[ "def", "remove", "(", "self", ",", "param", ",", "author", "=", "None", ")", ":", "if", "isinstance", "(", "param", ",", "SkillEntry", ")", ":", "skill", "=", "param", "else", ":", "skill", "=", "self", ".", "find_skill", "(", "param", ",", "author",...
Remove by url or name
[ "Remove", "by", "url", "or", "name" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L198-L208
train
42,892
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.update
def update(self, skill=None, author=None): """Update all downloaded skills or one specified skill.""" if skill is None: return self.update_all() else: if isinstance(skill, str): skill = self.find_skill(skill, author) entry = get_skill_entry(skill.name, self.skills_data) if entry: entry['beta'] = skill.is_beta if skill.update(): # On successful update update the update value if entry: entry['updated'] = time.time()
python
def update(self, skill=None, author=None): """Update all downloaded skills or one specified skill.""" if skill is None: return self.update_all() else: if isinstance(skill, str): skill = self.find_skill(skill, author) entry = get_skill_entry(skill.name, self.skills_data) if entry: entry['beta'] = skill.is_beta if skill.update(): # On successful update update the update value if entry: entry['updated'] = time.time()
[ "def", "update", "(", "self", ",", "skill", "=", "None", ",", "author", "=", "None", ")", ":", "if", "skill", "is", "None", ":", "return", "self", ".", "update_all", "(", ")", "else", ":", "if", "isinstance", "(", "skill", ",", "str", ")", ":", "...
Update all downloaded skills or one specified skill.
[ "Update", "all", "downloaded", "skills", "or", "one", "specified", "skill", "." ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L224-L237
train
42,893
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.apply
def apply(self, func, skills): """Run a function on all skills in parallel""" def run_item(skill): try: func(skill) return True except MsmException as e: LOG.error('Error running {} on {}: {}'.format( func.__name__, skill.name, repr(e) )) return False except: LOG.exception('Error running {} on {}:'.format( func.__name__, skill.name )) with ThreadPool(20) as tp: return tp.map(run_item, skills)
python
def apply(self, func, skills): """Run a function on all skills in parallel""" def run_item(skill): try: func(skill) return True except MsmException as e: LOG.error('Error running {} on {}: {}'.format( func.__name__, skill.name, repr(e) )) return False except: LOG.exception('Error running {} on {}:'.format( func.__name__, skill.name )) with ThreadPool(20) as tp: return tp.map(run_item, skills)
[ "def", "apply", "(", "self", ",", "func", ",", "skills", ")", ":", "def", "run_item", "(", "skill", ")", ":", "try", ":", "func", "(", "skill", ")", "return", "True", "except", "MsmException", "as", "e", ":", "LOG", ".", "error", "(", "'Error running...
Run a function on all skills in parallel
[ "Run", "a", "function", "on", "all", "skills", "in", "parallel" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L240-L258
train
42,894
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.install_defaults
def install_defaults(self): """Installs the default skills, updates all others""" def install_or_update_skill(skill): if skill.is_local: self.update(skill) else: self.install(skill, origin='default') return self.apply(install_or_update_skill, self.list_defaults())
python
def install_defaults(self): """Installs the default skills, updates all others""" def install_or_update_skill(skill): if skill.is_local: self.update(skill) else: self.install(skill, origin='default') return self.apply(install_or_update_skill, self.list_defaults())
[ "def", "install_defaults", "(", "self", ")", ":", "def", "install_or_update_skill", "(", "skill", ")", ":", "if", "skill", ".", "is_local", ":", "self", ".", "update", "(", "skill", ")", "else", ":", "self", ".", "install", "(", "skill", ",", "origin", ...
Installs the default skills, updates all others
[ "Installs", "the", "default", "skills", "updates", "all", "others" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L261-L270
train
42,895
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.list
def list(self): """ Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they have been downloaded to """ try: self.repo.update() except GitException as e: if not isdir(self.repo.path): raise LOG.warning('Failed to update repo: {}'.format(repr(e))) remote_skill_list = ( SkillEntry( name, SkillEntry.create_path(self.skills_dir, url, name), url, sha if self.versioned else '', msm=self ) for name, path, url, sha in self.repo.get_skill_data() ) remote_skills = { skill.id: skill for skill in remote_skill_list } all_skills = [] for skill_file in glob(join(self.skills_dir, '*', '__init__.py')): skill = SkillEntry.from_folder(dirname(skill_file), msm=self) if skill.id in remote_skills: skill.attach(remote_skills.pop(skill.id)) all_skills.append(skill) all_skills += list(remote_skills.values()) return all_skills
python
def list(self): """ Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they have been downloaded to """ try: self.repo.update() except GitException as e: if not isdir(self.repo.path): raise LOG.warning('Failed to update repo: {}'.format(repr(e))) remote_skill_list = ( SkillEntry( name, SkillEntry.create_path(self.skills_dir, url, name), url, sha if self.versioned else '', msm=self ) for name, path, url, sha in self.repo.get_skill_data() ) remote_skills = { skill.id: skill for skill in remote_skill_list } all_skills = [] for skill_file in glob(join(self.skills_dir, '*', '__init__.py')): skill = SkillEntry.from_folder(dirname(skill_file), msm=self) if skill.id in remote_skills: skill.attach(remote_skills.pop(skill.id)) all_skills.append(skill) all_skills += list(remote_skills.values()) return all_skills
[ "def", "list", "(", "self", ")", ":", "try", ":", "self", ".", "repo", ".", "update", "(", ")", "except", "GitException", "as", "e", ":", "if", "not", "isdir", "(", "self", ".", "repo", ".", "path", ")", ":", "raise", "LOG", ".", "warning", "(", ...
Load a list of SkillEntry objects from both local and remote skills It is necessary to load both local and remote skills at the same time to correctly associate local skills with the name in the repo and remote skills with any custom path that they have been downloaded to
[ "Load", "a", "list", "of", "SkillEntry", "objects", "from", "both", "local", "and", "remote", "skills" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L297-L330
train
42,896
MycroftAI/mycroft-skills-manager
msm/mycroft_skills_manager.py
MycroftSkillsManager.find_skill
def find_skill(self, param, author=None, skills=None): # type: (str, str, List[SkillEntry]) -> SkillEntry """Find skill by name or url""" if param.startswith('https://') or param.startswith('http://'): repo_id = SkillEntry.extract_repo_id(param) for skill in self.list(): if skill.id == repo_id: return skill name = SkillEntry.extract_repo_name(param) path = SkillEntry.create_path(self.skills_dir, param) return SkillEntry(name, path, param, msm=self) else: skill_confs = { skill: skill.match(param, author) for skill in skills or self.list() } best_skill, score = max(skill_confs.items(), key=lambda x: x[1]) LOG.info('Best match ({}): {} by {}'.format( round(score, 2), best_skill.name, best_skill.author) ) if score < 0.3: raise SkillNotFound(param) low_bound = (score * 0.7) if score != 1.0 else 1.0 close_skills = [ skill for skill, conf in skill_confs.items() if conf >= low_bound and skill != best_skill ] if close_skills: raise MultipleSkillMatches([best_skill] + close_skills) return best_skill
python
def find_skill(self, param, author=None, skills=None): # type: (str, str, List[SkillEntry]) -> SkillEntry """Find skill by name or url""" if param.startswith('https://') or param.startswith('http://'): repo_id = SkillEntry.extract_repo_id(param) for skill in self.list(): if skill.id == repo_id: return skill name = SkillEntry.extract_repo_name(param) path = SkillEntry.create_path(self.skills_dir, param) return SkillEntry(name, path, param, msm=self) else: skill_confs = { skill: skill.match(param, author) for skill in skills or self.list() } best_skill, score = max(skill_confs.items(), key=lambda x: x[1]) LOG.info('Best match ({}): {} by {}'.format( round(score, 2), best_skill.name, best_skill.author) ) if score < 0.3: raise SkillNotFound(param) low_bound = (score * 0.7) if score != 1.0 else 1.0 close_skills = [ skill for skill, conf in skill_confs.items() if conf >= low_bound and skill != best_skill ] if close_skills: raise MultipleSkillMatches([best_skill] + close_skills) return best_skill
[ "def", "find_skill", "(", "self", ",", "param", ",", "author", "=", "None", ",", "skills", "=", "None", ")", ":", "# type: (str, str, List[SkillEntry]) -> SkillEntry", "if", "param", ".", "startswith", "(", "'https://'", ")", "or", "param", ".", "startswith", ...
Find skill by name or url
[ "Find", "skill", "by", "name", "or", "url" ]
5acef240de42e8ceae2e82bc7492ffee33288b00
https://github.com/MycroftAI/mycroft-skills-manager/blob/5acef240de42e8ceae2e82bc7492ffee33288b00/msm/mycroft_skills_manager.py#L332-L362
train
42,897
twisted/vertex
vertex/ptcp.py
iterchunks
def iterchunks(data, chunksize): """iterate chunks of data """ offt = 0 while offt < len(data): yield data[offt:offt+chunksize] offt += chunksize
python
def iterchunks(data, chunksize): """iterate chunks of data """ offt = 0 while offt < len(data): yield data[offt:offt+chunksize] offt += chunksize
[ "def", "iterchunks", "(", "data", ",", "chunksize", ")", ":", "offt", "=", "0", "while", "offt", "<", "len", "(", "data", ")", ":", "yield", "data", "[", "offt", ":", "offt", "+", "chunksize", "]", "offt", "+=", "chunksize" ]
iterate chunks of data
[ "iterate", "chunks", "of", "data" ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L231-L237
train
42,898
twisted/vertex
vertex/ptcp.py
PTCPPacket.mustRetransmit
def mustRetransmit(self): """ Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted. """ if self.syn or self.fin or self.dlen: return True return False
python
def mustRetransmit(self): """ Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted. """ if self.syn or self.fin or self.dlen: return True return False
[ "def", "mustRetransmit", "(", "self", ")", ":", "if", "self", ".", "syn", "or", "self", ".", "fin", "or", "self", ".", "dlen", ":", "return", "True", "return", "False" ]
Check to see if this packet must be retransmitted until it was received. Packets which contain a connection-state changing flag (SYN or FIN) or a non-zero amount of data can be retransmitted.
[ "Check", "to", "see", "if", "this", "packet", "must", "be", "retransmitted", "until", "it", "was", "received", "." ]
feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca
https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/ptcp.py#L186-L196
train
42,899