output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def parseSyslog(msg):
"""Parses Syslog messages (RFC 5424)
The `Syslog Message Format (RFC 5424)
<https://tools.ietf.org/html/rfc5424#section-6>`_ can be parsed with
simple whitespace tokenization::
SYSLOG-MSG = HEADER SP STRUCTURED-DATA [SP MSG]
HEADER = PRI VERSION SP TIMESTAMP S... | Write a Python 3 script for
parsing Syslog messages into a dict keyed by the constituent parts of the Syslog message. | You are a Python code analyst, evaluating scripts for potential improvements. |
Return the creation time of the specified LogRecord as formatted
text. | Can you generate a brief explanation for the following Python 3 code
def formatTime (self, record, datefmt=None):
if datefmt is None:
datefmt = '%Y-%m-%d %H:%M:%S'
ct = self.converter(record.created)
t = time.strftime(datefmt, ct)
s = '%s.%03d' % (t, record.msecs)
... | You are a Python code generator, capable of creating scripts from specifications. |
def format (self, record):
"""Returns the given LogRecord as formatted text."""
record.hostname = self.hostname
return logging.Formatter.format(self, record) | Write a Python 3 script to
return the given LogRecord as formatted text. | As a Python code analyst, you investigate and solve complex coding mysteries |
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... | How would you code a function in Python 3 to
return the creation time of the given LogRecord as formatted text. | As a Python code composer, you craft elegant and concise scripts. |
def open (filename, mode='r', **options):
"""Returns an instance of a :class:`PCapStream` class which contains
the ``read()``, ``write()``, and ``close()`` methods. Binary mode
is assumed for this module, so the "b" is not required when
calling ``open()``.
If the optiontal ``rollover`` parameter i... | How would you code a function in Python 3 to
return an instance of a PCapStream class which contains the read write and close methods. | As a Python code translator, you convert algorithms and pseudocode into Python. |
This function takes a time range and input file and creates a new file with only
that subset of data. | Explain what the following Python 3 code does
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:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def segment(filenames, format, **options):
"""Segment the given pcap file(s) by one or more thresholds
(``nbytes``, ``npackets``, ``nseconds``). New segment filenames
are determined based on the ``strftime(3)`` ``format`` string
and the timestamp of the first packet in the file.
:param filenames: ... | Implement a Python 3 function for
segmenting the given pcap files by one or more thresholds. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Returns the time ranges available for the given file. | Make a summary of the following Python 3 code
def times(filenames, tolerance=2):
times = { }
delta = datetime.timedelta(seconds=tolerance)
if isinstance(filenames, str):
filenames = [ filenames ]
for filename in filenames:
with open(filename, 'r') as stream:
times[filename]... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Reads PCapGlobalHeader data from the given stream. | Can you generate a brief explanation for the following Python 3 code
def read (self, 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
... | As a Python code analyst, you investigate and solve complex coding mysteries |
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 =... | How would you code a function in Python 3 to
read PCapPacketHeader data from the given stream. | You are a Python code generator, capable of creating scripts from specifications. |
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:... | How would you implement a function in Python 3 that
indicates whether or not the file is being rollover to a new file. | You are a Python code generator, capable of creating scripts from specifications. |
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:
he... | Write a Python 3 script to
write a packet to the pcap file. | As a Python code analyst, you investigate and solve complex coding mysteries |
Closes this : class : PCapStream by closing the underlying Python
stream. | Can you generate the documentation for the following Python 3 function
def close (self):
if self._stream:
values = ( self._total.nbytes,
self._total.npackets,
int( math.ceil(self._total.nseconds) ),
self._filename )
if... | As a python code expert, you are capable of creating scripts from specifications. |
Returns the next header and packet from thisPCapStream. See read. | Can you generate the documentation for the following Python 3 function
def next (self):
header, packet = self.read()
if packet is None:
raise StopIteration
return header, packet | You are a Python code analyst, evaluating scripts for potential improvements. |
def read (self):
"""Reads a single packet from the this pcap stream, returning a
tuple (PCapPacketHeader, packet)
"""
header = PCapPacketHeader(self._stream, self.header._swap)
packet = None
if not header.incomplete():
packet = self._stream.read(header.incl_l... | How would you code a function in Python 3 to
read a single packet from the this pcap stream returning a tuple of header and packet. | You are a Python code analyst, evaluating scripts for potential improvements. |
This function writes a single entry to the file. It takes a byte array to write to the file as a single
PCAP packet and an optional header PCAP packet. | Can you tell what is the following Python 3 function doing
def write (self, bytes, header=None):
if type(bytes) is str:
bytes = bytearray(bytes)
if not isinstance(header, PCapPacketHeader):
header = PCapPacketHeader(orig_len=len(bytes))
packet = bytes[0:header.incl_len]... | As a Python code analyst, you investigate and solve complex coding mysteries |
def add (self, defn):
"""Adds the given Command Definition to this Command Dictionary."""
self[defn.name] = defn
self.colnames[defn.name] = defn | Write a Python 3 function that can
add the given Command Definition to this Command Dictionary. | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a new command with the given arguments. | How would you explain what the following Python 3 function does
def create (self, name, *args):
tab = None
defn = self.get(name, None)
if defn:
tab = FSWTab(defn, *args)
return tab | As a Python code translator, you convert algorithms and pseudocode into Python. |
Loads Command Definitions from the given YAML file into this Command Dictionary. | How would you explain what the following Python 3 function does
def load (self, filename):
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)
st... | As a Python code composer, you craft elegant and concise scripts. |
Publishes input message with client name as topic. | Can you generate the documentation for the following Python 3 function
def publish(self, msg):
self.pub.send("{} {}".format(self.name, msg))
log.debug('Published message from {}'.format(self)) | As a Python code composer, you craft elegant and concise scripts. |
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)
... | How would you implement a function in Python 3 that
creates a new database for the given Telemetry Dictionary and returns a connection to it. | As a python code expert, you are capable of creating scripts from specifications. |
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() | How would you implement a function in Python 3 that
creates a database table for the given PacketDefinition. | You are a Python code architect, reviewing and designing scalable and efficient code |
Inserts the given packet into the connected database. | How would you explain what the following Python 3 function does
def insert(dbconn, packet):
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... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def use(backend):
"""Use the given database backend, e.g. 'MySQLdb', 'psycopg2',
'MySQLdb', etc.
"""
global Backend
try:
Backend = importlib.import_module(backend)
except ImportError:
msg = 'Could not import (load) database.backend: %s' % backend
raise cfg.AitConfigError... | Can you create a Python 3 function that
uses the given database backend | You are a Python code analyst, evaluating scripts for potential improvements. |
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. Pa... | Implement a Python 3 function for
connecting to an InfluxDB instance and switch to a given database. | As a python code expert, you are capable of creating scripts from specifications. |
Create a database in a connected InfluxDB instance. | Given the following Python 3 function, write the documentation
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 t... | As a Python code composer, you craft elegant and concise scripts. |
def insert(self, packet, time=None, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
time
Optional parameter specifying the time value to use w... | Create a Python 3 function to
insert a packet into the database. | You are a Python code architect, reviewing and designing scalable and efficient code |
Generates AIT Packets from a InfluxDB query ResultSet object and returns a list of Packet objects. | Given the following Python 3 function, write the documentation
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... | As a Python code composer, you craft elegant and concise scripts. |
def connect(self, **kwargs):
''' Connect to a SQLite instance
**Configuration Parameters**
database
The database name or file to "connect" to. Defaults to **ait**.
'''
if 'database' not in kwargs:
kwargs['database'] = 'ait'
self._conn = ... | Can you write a function in Python 3 where it
connects to a SQLite instance holding the database name or file to be used for the database. | You are a Python code generator, capable of creating scripts from specifications. |
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`... | Write a Python 3 function that can
create a skeleton database for the current telemetry dictionary. | As a python code expert, you are capable of creating scripts from specifications. |
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.nam... | How would you code a function in Python 3 to
create a database table for the given PacketDefinition | You are a Python code generator, capable of creating scripts from specifications. |
def insert(self, packet, **kwargs):
''' Insert a packet into the database
Arguments
packet
The :class:`ait.core.tlm.Packet` instance to insert into
the database
'''
values = [ ]
pd = packet._defn
for defn in pd.fields:
... | Can you create a Python 3 function that
inserts a packet into the database. | As a Python code translator, you convert algorithms and pseudocode into 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' | Can you implement a function in Python 3 that
returns the SQL typename required to store the given FieldDefinition | You are a Python code architect, reviewing and designing scalable and efficient code |
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 sca... | How would you implement a function in Python 3 that
generates a map of vector lengths from the center point to each coordinate | As a python code expert, you are capable of creating scripts from specifications. |
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, "local... | How would you implement a function in Python 3 that
gives a datetime object adjust it according to the from_tz timezone into the to_tz timezone string. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def get_db_prep_save(self, value, connection=None):
"""
Returns field's value prepared for saving into a database.
"""
## convert to settings.TIME_ZONE
if value is not None:
if value.tzinfo is None:
value = default_tz.localize(value)
else:
... | Can you create a Python 3 function that
returns field s value prepared for saving into a database. | You are a Python code architect, reviewing and designing scalable and efficient code |
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 =... | Implement a function in Python 3 to
return field s value prepared for database lookup. | You are a Python code analyst, evaluating scripts for potential improvements. |
def liveNeighbours(self, z, y, x):
"""Returns the number of live neighbours."""
count = 0
for oz, oy, ox in self.offsets:
cz, cy, cx = z + oz, y + oy, x + ox
if cz >= self.depth:
cz = 0
if cy >= self.height:
cy = 0
... | How would you implement a function in Python 3 that
returns the number of live neighbours in a given location. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def turn(self):
"""Turn"""
r = (4, 5, 5, 5)
nt = copy.deepcopy(self.table)
for z in range(self.depth):
for y in range(self.height):
for x in range(self.width):
neighbours = self.liveNeighbours(z, y, x)
if self.ta... | How would you code a function in Python 3 to
turn the table into a new state. | You are a Python code architect, reviewing and designing scalable and efficient code |
Make a set of shaped random #'s for particle brightness deltas ( bd ) | Make a summary of the following Python 3 code
def make_bd(self):
"Make a set of 'shaped' random #'s for particle brightness deltas (bd)"
self.bd = concatenate((
# These values will dim the particles
random.normal(
self.bd_mean - self.bd_mu, self.bd_sigma, 16).asty... | You are a Python code analyst, evaluating scripts for potential improvements. |
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:
... | Implement a Python 3 function for
making a set of velocities to be randomly chosen for emitted particles | As a python code expert, you are capable of creating scripts from specifications. |
Move each particle by it s velocity adjusting brightness as we go. | How would you explain what the following Python 3 function does
def move_particles(self):
moved_particles = []
for vel, pos, stl, color, bright in self.particles:
stl -= 1 # steps to live
if stl > 0:
pos = pos + vel
if vel > 0:
... | As a python code expert, you are capable of creating scripts from specifications. |
Move each emitter by it s velocity. | Can you generate the documentation for the following Python 3 function
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 e_vel > 0:
if e_pos >= (self._end + 1):
... | You are a Python code architect, reviewing and designing scalable and efficient code |
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.
"""
... | Can you implement a function in Python 3 that
starts some new particles from the emitters. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Compute particle visibility based on distance between current strip position being rendered and particle position. | Here you have a function in Python 3, explain what it does
def visibility(self, strip_pos, particle_pos):
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
... | As a Python code composer, you craft elegant and concise scripts. |
Render visible particles at each strip position by modifying the color list. | Explain what the following Python 3 code does
def render_particles(self):
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_col... | You are a Python code generator, capable of creating scripts from specifications. |
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 | How would you implement a function in Python 3 that
makes a frame of the animation | As a Python code translator, you convert algorithms and pseudocode into 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 | Can you create a Python 3 function that
is the game over? | You are a Python code generator, capable of creating scripts from specifications. |
get_squares - Returns a list of all the squares that belong to a player | Can you generate the documentation for the following Python 3 function
def get_squares(self, player=None):
if player:
return [k for k, v in enumerate(self.squares) if v == player]
else:
return self.squares | You are a Python code generator, capable of creating scripts from specifications. |
Returns the number of live neighbours in the table. | How would you explain what the following Python 3 function does
def liveNeighbours(self, y, x):
count = 0
if y > 0:
if self.table[y - 1][x]:
count = count + 1
if x > 0:
if self.table[y - 1][x - 1]:
count = count + 1
... | You are a Python code analyst, evaluating scripts for potential improvements. |
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 | Create a Python 3 function to
create a Glycine residue | You are a Python code generator, capable of creating scripts from specifications. |
Creates an Alanine residue | Explain what the following Python 3 code does
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_ang... | As a python code expert, you are capable of creating scripts from specifications. |
Creates a Serine residue | Make a summary of the following Python 3 code
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
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates a Cysteine residue | How would you explain what the following Python 3 function does
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_... | You are a Python code generator, capable of creating scripts from specifications. |
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_CG... | Implement a function in Python 3 to
create a Valine residue | You are a Python code analyst, evaluating scripts for potential improvements. |
Creates an Isoleucine residue | How would you explain what the following Python 3 function does
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... | You are a Python code generator, capable of creating scripts from specifications. |
Creates a Leucine residue | Explain what the following Python 3 code does
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_angl... | You are a Python code analyst, evaluating scripts for potential improvements. |
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... | Implement a Python 3 function for
creating a Threonine residue | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates an Arginie residue | How would you explain what the following Python 3 function does
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... | You are a Python code architect, reviewing and designing scalable and efficient code |
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
... | How would you code a function in Python 3 to
create a Lysine residue | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates an Aspartic Acid residue | Given the following Python 3 function, write the documentation
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_... | You are a Python code analyst, evaluating scripts for potential improvements. |
Creates an Asparagine residue | Explain what the following Python 3 code does
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_C... | You are a Python code analyst, evaluating scripts for potential improvements. |
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_C... | How would you implement a function in Python 3 that
creates a Glutamic Acid residue | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates a Glutamine residue | Can you generate a brief explanation for the following Python 3 code
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_C... | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a Methionine residue | Can you tell what is the following Python 3 function doing
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=ge... | As a python code expert, you are capable of creating scripts from specifications. |
Creates a Histidine residue. | Can you generate the documentation for the following Python 3 function
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_... | As a Python code composer, you craft elegant and concise scripts. |
Creates a Proline residue | Can you generate a brief explanation for the following Python 3 code
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_... | You are a Python code generator, capable of creating scripts from specifications. |
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_... | Write a Python 3 script to
create a Phenylalanine residue. | As a Python code analyst, you investigate and solve complex coding mysteries |
Creates a Tryptophan residue. | Can you tell what is the following Python 3 function doing
def makeTrp(segID, N, CA, C, O, geo):
'''Creates a Tryptophan 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=ge... | You are a Python code analyst, evaluating scripts for potential improvements. |
def initialize_res(residue):
'''Creates a new structure containing a single amino acid. The type and
geometry of the amino acid are determined by the argument, which has to be
either a geometry object or a single-letter amino acid code.
The amino acid will be placed into chain A of model 0.'''
... | Write a Python 3 function for
creating a new structure containing a single amino acid. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def add_residue_from_geo(structure, geo):
'''Adds a residue to chain A model 0 of the given structure, and
returns the new structure. The residue to be added is determined by
the geometry object given as second argument.
This function is a helper function and should not normally be called
direc... | How would you implement a function in Python 3 that
adds a residue to chain A model 0 of the given structure and returns the new structure. | As a Python code analyst, you investigate and solve complex coding mysteries |
Place a sequence of amino acids into a peptide in the extended
conformation. The argument AA_chain holds the amino acids to be used. | Can you generate the documentation for the following Python 3 function
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=initi... | As a Python code composer, you craft elegant and concise scripts. |
Adds a residue to the chain A model 0 of the given structure and returns the new structure. | Can you generate the documentation for the following Python 3 function
def add_residue(structure, residue, phi=-120, psi_im1=140, omega=-370):
'''Adds a residue to chain A model 0 of the given structure, and
returns the new structure. The residue to be added can be specified
in two ways: either as a geometr... | You are a Python code generator, capable of creating scripts from specifications. |
Place a sequence of amino acids into a peptide with specified backbone dihedral angles. | Can you generate a brief explanation for the following Python 3 code
def make_structure(AA_chain,phi,psi_im1,omega=[]):
'''Place a sequence of amino acids into a peptide with specified
backbone dihedral angles. The argument AA_chain holds the
sequence of amino acids to be used. The arguments phi and psi_im1... | As a Python code composer, you craft elegant and concise scripts. |
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 | How would you implement a function in Python 3 that
creates a structure out of a list of geometry objects. | You are a Python code architect, reviewing and designing scalable and efficient code |
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()
... | Write a Python 3 function that can
generate the geometry of the requested amino acid. | You are a Python code generator, capable of creating scripts from specifications. |
Register a new account and return a Deferred that fires if it worked. | Can you tell what is the following Python 3 function doing
def enregister(svc, newAddress, password):
return svc.connectQ2Q(q2q.Q2QAddress("",""),
q2q.Q2QAddress(newAddress.domain, "accounts"),
'identity-admin',
protocol.ClientFactory.forProtocol(... | As a Python code composer, you craft elegant and concise scripts. |
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
""... | Implement a function in Python 3 to
connect the given endpoint to the given protocolFactory. | You are a Python code analyst, evaluating scripts for potential improvements. |
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._... | Write a Python 3 function that can
remove lost connection from cache. | You are a Python code generator, capable of creating scripts from specifications. |
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()}
... | Can you write a function in Python 3 where it
disconnects all cached connections. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Convert a string or bool into a bool. | How would you explain what the following Python 3 function does
def parse_state(state):
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:
... | As a Python code translator, you convert algorithms and pseudocode into 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 ser... | Can you write a function in Python 3 where it
extracts the Zipkin attributes and configuration from the request attributes. | As a Python code analyst, you investigate and solve complex coding mysteries |
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... | How would you implement a function in Python 3 that
returns a pyramid tween function for the given pyramid request handler and pyramid app registry. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Generates tuples of name path url sha | Explain what the following Python 3 code does
def get_skill_data(self):
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:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
Sets the ackPredicate to True if the most recent packet produced as an output of this state machine has been acknowledged by our peer. | Make a summary of the following Python 3 code
def expectAck(self):
last = self.lastTransmitted
self.ackPredicate = lambda ackPacket: (
ackPacket.relativeAck() >= last.relativeSeq()
) | You are a Python code generator, capable of creating scripts from specifications. |
def maybeReceiveAck(self, ackPacket):
"""
Receive an L{ack} or L{synAck} input from the given packet.
"""
ackPredicate = self.ackPredicate
self.ackPredicate = lambda packet: False
if ackPacket.syn:
# New SYN packets are always news.
self.synAck()
... | Implement a function in Python 3 to
receive an ack or SynAck packet from the given packet. | You are a Python code analyst, evaluating scripts for potential improvements. |
Set the options for CleanCommand.
| Can you tell what is the following Python 3 function doing
def _set_options():
CleanCommand.user_options = _CleanCommand.user_options[:]
CleanCommand.user_options.extend([
('dist', 'd', 'remove distribution directory'),
('eggs', None, 'remove egg and egg-info directories'),
('environment... | You are a Python code architect, reviewing and designing scalable and efficient code |
Activates a universe that s then starting to sending every second. | Make a summary of the following Python 3 code
def activate_output(self, universe: int) -> None:
check_universe(universe)
# check, if the universe already exists in the list:
if universe in self._outputs:
return
# add new sending:
new_output = Output(DataPacket(cid=sel... | You are a Python code architect, reviewing and designing scalable and efficient code |
Deactivates an existing sending output. | Can you generate the documentation for the following Python 3 function
def deactivate_output(self, universe: int) -> None:
check_universe(universe)
try: # try to send out three messages with stream_termination bit set to 1
self._outputs[universe]._packet.option_StreamTerminated = True
... | As a Python code composer, you craft elegant and concise scripts. |
def move_universe(self, universe_from: int, universe_to: int) -> None:
"""
Moves an sending from one universe to another. All settings are being restored and only the universe changes
:param universe_from: the universe that should be moved
:param universe_to: the target universe. An exis... | Can you write a function in Python 3 where it
moves an entry from one universe to another. | As a Python code translator, you convert algorithms and pseudocode into Python. |
def start(self, bind_address=None, bind_port: int = None, fps: int = None) -> None:
"""
Starts or restarts a new Thread with the parameters given in the constructor or
the parameters given in this function.
The parameters in this function do not override the class specific values!
... | Implement a function in Python 3 to
start or restarts a new Thread with the parameters given in the constructor. | You are a Python code analyst, evaluating scripts for potential improvements. |
Open a file object for reading and writing. | Can you generate the documentation for the following Python 3 function
def openReadWrite(filename):
try:
os.makedirs(os.path.dirname(filename))
except OSError:
pass
try:
return file(filename, 'rb+')
except IOError:
return file(filename, 'wb+') | As a Python code analyst, you investigate and solve complex coding mysteries |
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 | Write a Python 3 script for
opening the bitmask file in the filesystem. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Issue a DATA command on the local cache | Can you generate a brief explanation for the following Python 3 code
def data(self, name, chunk, body):
self.callRemote(Data, name=name, chunk=chunk, body=body) | As a Python code composer, you craft elegant and concise scripts. |
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:
peer... | Write a Python 3 script to
issue a GET command on the related nexus object and return the size of the name being requested. | You are a Python code analyst, evaluating scripts for potential improvements. |
def connectionLost(self, reason):
"""
Inform the associated L{conncache.ConnectionCache} that this
protocol has been disconnected.
"""
self.nexus.conns.connectionLostForKey((endpoint.Q2QEndpoint(
self.nexus.svc,
self.nexus.addr,
sel... | Create a Python 3 function to
notify AMP that a connection has been lost. | You are a Python code architect, reviewing and designing scalable and efficient code |
def sendSomeData(self, howMany):
"""
Send some DATA commands to my peer(s) to relay some data.
@param howMany: an int, the number of chunks to send out.
"""
# print 'sending some data', howMany
if self.transport is None:
return
peer = self.transport.g... | How would you code a function in Python 3 to
send some DATA commands to my peer. | As a Python code translator, you convert algorithms and pseudocode into 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(pee... | Implement a function in Python 3 to
choose a peer to introduce. | You are a Python code analyst, evaluating scripts for potential improvements. |
This method is called when a chunk has been verified. | Make a summary of the following Python 3 code
def chunkVerified(self, who, chunkNumber, chunkData):
if self.mask[chunkNumber]:
# already received that chunk.
return
self.file.seek(chunkNumber * CHUNK_SIZE)
self.file.write(chunkData)
self.file.flush()
self.... | As a Python code composer, you craft elegant and concise scripts. |
select an optimal chunk to send to a peer. | Given the following Python 3 function, write the documentation
def selectOptimalChunk(self, peer):
# 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)
... | You are a Python code generator, capable of creating scripts from specifications. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.