output stringlengths 1 928k | instruction stringlengths 7 928k | system stringlengths 0 104k |
|---|---|---|
def post_gist(report_data, old_sha, new_sha):
"""Post the report to a GitHub Gist and return the URL of the gist."""
payload = {
"description": ("Changes in OpenStack-Ansible between "
"{0} and {1}".format(old_sha, new_sha)),
"public": True,
"files": {
... | How would you implement a function in Python 3 that
posts the report to a GitHub Gist and return the URL of the gist. | As a Python code analyst, you investigate and solve complex coding mysteries |
Prepare the storage directory. | Given the following Python 3 function, write the documentation
def prepare_storage_dir(storage_directory):
storage_directory = os.path.expanduser(storage_directory)
if not os.path.exists(storage_directory):
os.mkdir(storage_directory)
return storage_directory | As a Python code translator, you convert algorithms and pseudocode into Python. |
def render_template(template_file, template_vars):
"""Render a jinja template."""
# Load our Jinja templates
template_dir = "{0}/templates".format(
os.path.dirname(os.path.abspath(__file__))
)
jinja_env = jinja2.Environment(
loader=jinja2.FileSystemLoader(template_dir),
trim_... | Can you implement a function in Python 3 that
renders a jinja template. | As a python code expert, you are capable of creating scripts from specifications. |
def repo_pull(repo_dir, repo_url, fetch=False):
"""Reset repository and optionally update it."""
# Make sure the repository is reset to the master branch.
repo = Repo(repo_dir)
repo.git.clean("-df")
repo.git.reset("--hard")
repo.git.checkout("master")
repo.head.reset(index=True, working_tree... | Create a Python 3 function for
resetting repository and optionally update it. | You are a Python code generator, capable of creating scripts from specifications. |
def update_repo(repo_dir, repo_url, fetch=False):
"""Clone the repo if it doesn't exist already, otherwise update it."""
repo_exists = os.path.exists(repo_dir)
if not repo_exists:
log.info("Cloning repo {}".format(repo_url))
repo = repo_clone(repo_dir, repo_url)
# Make sure the repo is ... | Write a Python 3 function for
cloning the repo if it doesn t exist already otherwise update it. | You are a Python code generator, capable of creating scripts from specifications. |
def validate_commits(repo_dir, commits):
"""Test if a commit is valid for the repository."""
log.debug("Validating {c} exist in {r}".format(c=commits, r=repo_dir))
repo = Repo(repo_dir)
for commit in commits:
try:
commit = repo.commit(commit)
except Exception:
msg... | How would you code a function in Python 3 to
test if a commit exists in the repository. | As a Python code composer, you craft elegant and concise scripts. |
Check if commit range is valid. Flip it if needed. | Given the following Python 3 function, write the documentation
def validate_commit_range(repo_dir, old_commit, new_commit):
# Are there any commits between the two commits that were provided?
try:
commits = get_commits(repo_dir, old_commit, new_commit)
except Exception:
commits = []
if l... | As a Python code composer, you craft elegant and concise scripts. |
Get release notes between the two revisions. | Can you tell what is the following Python 3 function doing
def get_release_notes(osa_repo_dir, osa_old_commit, osa_new_commit):
repo = Repo(osa_repo_dir)
# Get a list of tags, sorted
tags = repo.git.tag().split('\n')
tags = sorted(tags, key=LooseVersion)
# Currently major tags are being printed aft... | You are a Python code generator, capable of creating scripts from specifications. |
def append_all_below(destination, source, join_str=None):
"""
Compared to xml.dom.minidom, lxml's treatment of text as .text and .tail
attributes of elements is an oddity. It can even be a little frustrating
when one is attempting to copy everything underneath some element to
another element; one ha... | Write a Python 3 script to
compare to xml.dom.minidom, lxml's treatment of text as .text and .tail attributes of elements is an oddity. It can even be a little frustrating when one is attempting to copy everything underneath some element to another element; one has to write in extra code to handle the text. This method... | You are a Python code analyst, evaluating scripts for potential improvements. |
This method returns all text data underneath the given element. | Given the following Python 3 function, write the documentation
def all_text(element):
if element.text is None:
text = []
else:
text = [element.text]
tails = [child.tail for child in element if child.tail is not None]
tails = [tail.strip() for tail in tails if tail.strip()]
return ' '... | As a Python code translator, you convert algorithms and pseudocode into Python. |
This method returns a convenient method for adapting a tag or attribute name to a tag or attribute name. | Can you tell what is the following Python 3 function doing
def ns_format(element, namespaced_string):
if ':' not in namespaced_string:
print('This name contains no namespace, returning it unmodified: ' + namespaced_string)
return namespaced_string
namespace, name = namespaced_string.split(':')
... | As a python code expert, you are capable of creating scripts from specifications. |
Renames the attributes of the element. | How would you explain what the following Python 3 function does
def rename_attributes(element, attrs):
for name in attrs.keys():
if name not in element.attrib:
continue
else:
element.attrib[attrs[name]] = element.attrib.pop(name) | As a Python code analyst, you investigate and solve complex coding mysteries |
A simple way to replace one element node with another. | Make a summary of the following Python 3 code
def replace(old, new):
parent = old.getparent()
parent.replace(old, new) | As a Python code analyst, you investigate and solve complex coding mysteries |
def comment(node):
"""
Converts the node received to a comment, in place, and will also return the
comment element.
"""
parent = node.parentNode
comment = node.ownerDocument.createComment(node.toxml())
parent.replaceChild(comment, node)
return comment | Can you create a Python 3 function that
converts the node received to a comment in place and returns the comment element. | You are a Python code generator, capable of creating scripts from specifications. |
Converts the comment node received to a non - commented element in place and returns the new node. | Here you have a function in Python 3, explain what it does
def uncomment(comment):
parent = comment.parentNode
h = html.parser.HTMLParser()
data = h.unescape(comment.data)
try:
node = minidom.parseString(data).firstChild
except xml.parsers.expat.ExpatError: # Could not parse!
log.er... | As a python code expert, you are capable of creating scripts from specifications. |
def serialize(element, strip=False):
"""
A handy way to serialize an element to text.
"""
text = etree.tostring(element, method='text', encoding='utf-8')
if strip:
text = text.strip()
return str(text, encoding='utf-8') | Write a Python 3 script for
serializing an element to text. | As a Python code composer, you craft elegant and concise scripts. |
def get_arg_parse():
"""Parses the Command Line Arguments using argparse."""
# Create parser object:
objParser = argparse.ArgumentParser()
# Add argument to namespace -config file path:
objParser.add_argument('-config', required=True,
metavar='/path/to/config.csv',
... | Write a Python 3 function that can
parse the Command Line Arguments using argparse. | As a Python code composer, you craft elegant and concise scripts. |
Make data filter definition consistent. | Given the following Python 3 function, write the documentation
def _homogenize_data_filter(dfilter):
if isinstance(dfilter, tuple) and (len(dfilter) == 1):
dfilter = (dfilter[0], None)
if (dfilter is None) or (dfilter == (None, None)) or (dfilter == (None,)):
dfilter = (None, None)
elif isin... | You are a Python code generator, capable of creating scripts from specifications. |
Convert to float string. | Explain what the following Python 3 code does
def _tofloat(obj):
if "inf" in obj.lower().strip():
return obj
try:
return int(obj)
except ValueError:
try:
return float(obj)
except ValueError:
return obj | As a Python code composer, you craft elegant and concise scripts. |
def _in_header(self, col):
"""Validate column identifier(s)."""
# pylint: disable=R1704
if not self._has_header:
# Conditionally register exceptions so that they do not appear
# in situations where has_header is always True. In this way
# they are not auto-doc... | Create a Python 3 function for
validating column identifier ( s ). | You are a Python code generator, capable of creating scripts from specifications. |
def _validate_rfilter(self, rfilter, letter="d"):
"""Validate that all columns in filter are in header."""
if letter == "d":
pexdoc.exh.addai(
"dfilter",
(
(not self._has_header)
and any([not isinstance(item, int) for it... | Write a Python 3 script to
validate that all columns in filter are in header. | You are a Python code generator, capable of creating scripts from specifications. |
r Returns the file data. | Can you tell what is the following Python 3 function doing
def data(self, filtered=False, no_empty=False):
return self._apply_filter(filtered, no_empty) | As a Python code composer, you craft elegant and concise scripts. |
r Returns the data header. | Can you generate the documentation for the following Python 3 function
def header(self, filtered=False):
return (
self._header
if (not filtered) or (filtered and self._cfilter is None)
else self._cfilter
) | As a python code expert, you are capable of creating scripts from specifications. |
r Write the data to a specified comma - separated values file. | How would you explain what the following Python 3 function does
def write(self, fname=None, filtered=False, header=True, append=False):
# pylint: disable=R0913
write_ex = pexdoc.exh.addex(ValueError, "There is no data to save to file")
fname = self._fname if fname is None else fname
data... | As a Python code analyst, you investigate and solve complex coding mysteries |
Create or load pRF model time courses. | Can you generate the documentation for the following Python 3 function
def model_creation(dicCnfg, varRat=None, strPathHrf=None):
# *************************************************************************
# *** Load parameters from config file
# Load config parameters from dictionary into namespace:
c... | As a Python code translator, you convert algorithms and pseudocode into Python. |
요청처트 정보 요청처트 정보 요청처트 정보 요청처트 정보 요청처트 정� | How would you explain what the following Python 3 function does
def register(self, CorpNum, cashbill, UserID=None):
if cashbill == None:
raise PopbillException(-99999999, "현금영수증 정보가 입력되지 않았습니다.")
postData = self._stringtify(cashbill)
return self._httppost('/Cashbill', postDat... | You are a Python code analyst, evaluating scripts for potential improvements. |
A method to update a single entry in a particular resource. | Here you have a function in Python 3, explain what it does
def update(self, CorpNum, MgtKey, cashbill, UserID=None):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
if cashbill == None:
raise PopbillException(-99999999, "현금영수증 정보가 입력되... | As a python code expert, you are capable of creating scripts from specifications. |
def issue(self, CorpNum, MgtKey, Memo=None, UserID=None):
""" 발행
args
CorpNum : 팝빌회원 사업자번호
MgtKey : 원본 현금영수증 문서관리번호
Memo : 발행 메모
UserID : 팝빌회원 아이디
return
처리결과. consist of code and message
... | Write a Python 3 function that can
issue a new entry in the specified resource. | As a python code expert, you are capable of creating scripts from specifications. |
삭제 제 영수증 현금영수증 서 정보 않았습니다. | Given the following Python 3 function, write the documentation
def delete(self, CorpNum, MgtKey, UserID=None):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
return self._httppost('/Cashbill/' + MgtKey, '', CorpNum, UserID, "DELETE") | You are a Python code generator, capable of creating scripts from specifications. |
Get information about a particular item. | Can you generate the documentation for the following Python 3 function
def getInfo(self, CorpNum, MgtKey):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
return self._httpget('/Cashbill/' + MgtKey, CorpNum) | You are a Python code analyst, evaluating scripts for potential improvements. |
def getDetailInfo(self, CorpNum, MgtKey):
""" 상세정보 조회
args
CorpNum : 팝빌회원 사업자번호
MgtKey : 문서관리번호
return
문서 상세정보 object
raise
PopbillException
"""
if MgtKey == None or MgtKey == "":
... | Create a Python 3 function to
get the details of a particular item. | As a Python code composer, you craft elegant and concise scripts. |
문서이력 조회
args
CorpNum : 팝빌회원 사업자번호
MgtKey : 문서관리번호
return
문서 이력 목록 as List
raise
PopbillException | Can you generate the documentation for the following Python 3 function
def getLogs(self, CorpNum, MgtKey):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
return self._httpget('/Cashbill/' + MgtKey + '/Logs', CorpNum) | As a Python code analyst, you investigate and solve complex coding mysteries |
전송 요청한 정보 요청한 정보 요청한 정보 요청한 정보 요청한 정보 요청해요과과과 요자 정보 요자 정보 요자 정보 요자 정보 요요과 요요자 정보 요자 정보 요자 정보 정보정보정보요자 자 정보요요요요요요요요요자 요자 정보 요자 정보 정보요요요자 자 요요요요요요요요요요요요요요요요요요요요요요요자 자 요요요요요요자 자 요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요요... | Make a summary of the following Python 3 code
def updateEmailConfig(self, Corpnum, EmailType, SendYN, UserID=None):
if EmailType == None or EmailType == '':
raise PopbillException(-99999999, "메일전송 타입이 입력되지 않았습니다.")
if SendYN == None or SendYN == '':
raise PopbillException(-... | As a python code expert, you are capable of creating scripts from specifications. |
Returns the list of documents found on the collection | Make a summary of the following Python 3 code
def list(self, request):
pipeline = [{'$match': request.args.pop('match', {})}]
sort = request.args.pop('sort', {})
if sort:
pipeline.append({'$sort': sort})
project = request.args.pop('project', {})
if project:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def create(self, request):
"""
Creates a new document based on the given data
"""
document = self.collection(request.json)
document.created_at = datetime.utcnow()
document.updated_at = document.created_at
created = document.insert()
return Response(
... | Write a Python 3 script to
create a new document based on the given data. | As a Python code analyst, you investigate and solve complex coding mysteries |
def retrieve(self, request, _id):
"""
Returns the document containing the given _id or 404
"""
_id = deserialize(_id)
retrieved = self.collection.find_one({'_id': _id})
if retrieved:
return Response(serialize(retrieved))
else:
return Respo... | Create a Python 3 function for
retrieving the document with the given _id or 404 | As a Python code analyst, you investigate and solve complex coding mysteries |
def update(self, request, _id):
"""
Updates the document with the given _id using the given data
"""
_id = deserialize(_id)
to_update = self.collection.find_one({'_id': _id})
if to_update:
document = self.collection(dict(to_update, **request.json))
... | How would you implement a function in Python 3 that
updates the document with the given _id using the given data | As a python code expert, you are capable of creating scripts from specifications. |
def delete(self, request, _id):
"""
Deletes the document with the given _id if it exists
"""
_id = deserialize(_id)
to_delete = self.collection.get({'_id': _id})
if to_delete:
deleted = to_delete.delete()
return Response(
response... | Write a Python 3 function for
deleting the document with the given _id if it exists. | As a Python code composer, you craft elegant and concise scripts. |
Decorator for test functions that require a running reactor. | Given the following Python 3 function, write the documentation
def with_reactor(*dec_args, **dec_kwargs):
# This method takes care of the decorator protocol, it
# distinguishes between using the decorator with brackets
# and without brackets. It then calls `_twisted_test_sync()`.
if len(dec_args) ... | You are a Python code analyst, evaluating scripts for potential improvements. |
def _ensure_reactor_running():
"""
Starts the twisted reactor if it is not running already.
The reactor is started in a new daemon-thread.
Has to perform dirty hacks so that twisted can register
signals even if it is not running in the main-thread.
"""
if not reactor.running:
... | Create a Python 3 function to
start the twisted reactor if it is not running already. | As a python code expert, you are capable of creating scripts from specifications. |
Cancels the given deferred after the given time. | Can you tell what is the following Python 3 function doing
def _timeoutDeferred(deferred, timeout):
delayedCall = reactor.callLater(timeout, deferred.cancel)
def gotResult(result):
if delayedCall.active():
delayedCall.cancel()
return result
deferred.addBoth(gotResult) | You are a Python code generator, capable of creating scripts from specifications. |
This function finds the best fitting pRF model for a specific voxel time course using the CPU. | Can you generate a brief explanation for the following Python 3 code
def find_prf_cpu(idxPrc, aryFuncChnk, aryPrfTc, aryMdlParams, strVersion,
lgcXval, varNumXval, queOut, lgcRstr=None, lgcPrint=True):
"""
Find best fitting pRF model for voxel time course, using the CPU.
Parameters
---... | As a python code expert, you are capable of creating scripts from specifications. |
def check(schema, rev_id, page_id=None, radius=defaults.RADIUS,
before=None, window=None):
"""
Checks the revert status of a revision. With this method, you can
determine whether an edit is a 'reverting' edit, was 'reverted' by another
edit and/or was 'reverted_to' by another edit.
:Para... | Write a Python 3 script to
check the revert status of a revision. With this method, you can determine whether an edit is a 'reverting' edit, was 'reverted' by another edit and/or was 'reverted_to' by another edit. :Parameters: session : :class:`mwapi.Session` An API session to make use of rev_id : int the ID of the rev... | As a Python code composer, you craft elegant and concise scripts. |
Checks the revert status of an archived revision. | Can you generate a brief explanation for the following Python 3 code
def check_archive(schema, rev_id, namespace=None, title=None, timestamp=None,
radius=defaults.RADIUS,
before=None, window=None):
"""
Checks the revert status of an archived revision (from a deleted page).
... | As a Python code composer, you craft elegant and concise scripts. |
def _get_json(value):
"""Convert the given value to a JSON object."""
if hasattr(value, 'replace'):
value = value.replace('\n', ' ')
try:
return json.loads(value)
except json.JSONDecodeError:
# Escape double quotes.
if hasattr(value, 'replace'):
value = value.... | Write a Python 3 function that can
convert the given value to a JSON object. | As a python code expert, you are capable of creating scripts from specifications. |
Convert the given list of parameters to a JSON object. | Given the following Python 3 function, write the documentation
def save_list(key, *values):
return json.dumps({key: [_get_json(value) for value in values]}) | You are a Python code analyst, evaluating scripts for potential improvements. |
def save_file(key, file_path, *refs):
"""Convert the given parameters to a special JSON object.
JSON object is of the form:
{ key: {"file": file_path}}, or
{ key: {"file": file_path, "refs": [refs[0], refs[1], ... ]}}
"""
if not os.path.isfile(file_path):
return error("Output '{}' set ... | Can you implement a function in Python 3 that
converts the given parameters to a special JSON object. | As a python code expert, you are capable of creating scripts from specifications. |
def save_file_list(key, *files_refs):
"""Convert the given parameters to a special JSON object.
Each parameter is a file-refs specification of the form:
<file-path>:<reference1>,<reference2>, ...,
where the colon ':' and the list of references are optional.
JSON object is of the form:
{ key: {... | Implement a function in Python 3 to
convert the given parameters to a special JSON object. | As a Python code analyst, you investigate and solve complex coding mysteries |
Convert the given parameters to a special JSON object. | Here you have a function in Python 3, explain what it does
def save_dir(key, dir_path, *refs):
if not os.path.isdir(dir_path):
return error(
"Output '{}' set to a missing directory: '{}'.".format(key, dir_path)
)
result = {key: {"dir": dir_path}}
if refs:
missing_refs =... | You are a Python code generator, capable of creating scripts from specifications. |
Convert the given parameters to a special JSON object. | Here you have a function in Python 3, explain what it does
def save_dir_list(key, *dirs_refs):
dir_list = []
for dir_refs in dirs_refs:
if ':' in dir_refs:
try:
dir_path, refs = dir_refs.split(':')
except ValueError as e:
return error("Only one col... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Convert given progress to a JSON object. | Can you tell what is the following Python 3 function doing
def progress(progress):
if isinstance(progress, int) or isinstance(progress, float):
progress = float(progress)
else:
try:
progress = float(json.loads(progress))
except (TypeError, ValueError):
return warn... | You are a Python code analyst, evaluating scripts for potential improvements. |
Check if return code is in list that contains acceptable return codes. | Can you generate a brief explanation for the following Python 3 code
def checkrc(rc, *args):
try:
rc = int(rc)
except (TypeError, ValueError):
return error("Invalid return code: '{}'.".format(rc))
acceptable_rcs = []
error_msg = ""
if len(args):
for code in args[:-1]:
... | As a Python code composer, you craft elegant and concise scripts. |
Imports a file from a source file to a target file. | Given the following Python 3 function, write the documentation
def import_file(
src,
file_name,
imported_format=ImportedFormat.BOTH,
progress_from=0.0,
progress_to=None,
):
"""Import file to working directory.
:param src: Source file path or URL
:param file_name: Source file name
:p... | You are a Python code generator, capable of creating scripts from specifications. |
def loadNiiData(lstNiiFls,
strPathNiiMask=None,
strPathNiiFunc=None):
"""load nii data.
Parameters
----------
lstNiiFls : list, list of str with nii file names
strPathNiiMask : str, path to nii file with mask (optional)
strPathNiiFunc : str, p... | Write a Python 3 script to
load nii data from nii files | You are a Python code architect, reviewing and designing scalable and efficient code |
def calcR2(predTst, yTest, axis=0):
"""calculate coefficient of determination. Assumes that axis=0 is time
Parameters
----------
predTst : np.array, predicted reponse for yTest
yTest : np.array, acxtually observed response for yTest
Returns
-------
aryFunc : ... | Write a Python 3 script for
calculating coefficient of determination. Assumes that axis = 0 is time | As a Python code analyst, you investigate and solve complex coding mysteries |
calculate coefficient of determination. Assumes that axis = 0 is time
| Can you tell what is the following Python 3 function doing
def calcFstats(predTst, yTest, p, axis=0):
rss = np.sum((yTest - predTst) ** 2, axis=axis)
tss = np.sum((yTest - yTest.mean()) ** 2, axis=axis)
# derive number of measurements
n = yTest.shape[0]
# calculate Fvalues
vecFvals = ((tss - rss... | As a python code expert, you are capable of creating scripts from specifications. |
calculate mean squared error. Assumes that axis = 0 is time
getTerminal | Can you generate a brief explanation for the following Python 3 code
def calcMse(predTst, yTest, axis=0):
return np.mean((yTest - predTst) ** 2, axis=axis) | As a Python code translator, you convert algorithms and pseudocode into Python. |
def detect(checksum_revisions, radius=defaults.RADIUS):
"""
Detects reverts that occur in a sequence of revisions. Note that,
`revision` data meta will simply be returned in the case of a revert.
This function serves as a convenience wrapper around calls to
:class:`mwreverts.Detector`'s :func:`~mw... | Write a Python 3 script for
detecting reverts that occur in a sequence of revisions. | As a Python code translator, you convert algorithms and pseudocode into Python. |
요청번호 Returns a list of ChargeInfo objects. | Can you tell what is the following Python 3 function doing
def getChargeInfo(self, CorpNum, ItemCode, UserID=None):
if ItemCode == None or ItemCode == '':
raise PopbillException(-99999999, "명세서 종류 코드가 입력되지 않았습니다.")
return self._httpget('/Statement/ChargeInfo/' + ItemCode, CorpNum, UserI... | As a Python code analyst, you investigate and solve complex coding mysteries |
전자번호 전자번호 정서 � | Can you generate the documentation for the following Python 3 function
def getUnitCost(self, CorpNum, ItemCode):
if ItemCode == None or ItemCode == "":
raise PopbillException(-99999999, "명세서 종류 코드가 입력되지 않았습니다.")
result = self._httpget('/Statement/' + str(ItemCode) + '?cfg=UNITCOST', Cor... | As a python code expert, you are capable of creating scripts from specifications. |
즉시발행
args
CorpNum : 팝빌회원 사업자번호
statement : 등록할 전자명세서 object. made with Statement(...)
Memo : 즉시발행메모
UserID : 팝빌회원 아이디
return
처리결과. consist of code and message
raise
PopbillExcep... | Given the following Python 3 function, write the documentation
def registIssue(self, CorpNum, statement, Memo=None, UserID=None):
if statement == None:
raise PopbillException(-99999999, "등록할 전자명세서 정보가 입력되지 않았습니다.")
if Memo != None or Memo != '':
statement.memo = Memo
... | You are a Python code analyst, evaluating scripts for potential improvements. |
임시저장
args
CorpNum : 팝빌회원 사업자번호
statement : 등록할 전자명세서 object. made with Statement(...)
UserID : 팝빌회원 아이디
return
처리결과. consist of code and message
raise
PopbillException | How would you explain what the following Python 3 function does
def register(self, CorpNum, statement, UserID=None):
if statement == None:
raise PopbillException(-99999999, "등록할 전자명세서 정보가 입력되지 않았습니다.")
postData = self._stringtify(statement)
return self._httppost('/Statement',... | As a Python code composer, you craft elegant and concise scripts. |
임시저장
args
CorpNum : 팝빌회원 사업자번호
ItemCode : 명세서 종류 코드
[121 - 거래명세서], [122 - 청구서], [123 - 견적서],
[124 - 발주서], [125 - 입금표], [126 - 영수증]
MgtKey : 파트너 문서관리번호
Statement : 등록할 전자명세서 object. made with Statem... | Given the following Python 3 function, write the documentation
def update(self, CorpNum, ItemCode, MgtKey, Statement, UserID=None):
if Statement == None:
raise PopbillException(-99999999, "등록할 전자명세서 정보가 입력되지 않았습니다.")
if MgtKey == None or MgtKey == "":
raise PopbillException... | As a python code expert, you are capable of creating scripts from specifications. |
def issue(self, CorpNum, ItemCode, MgtKey, Memo=None, EmailSubject=None, UserID=None):
""" 발행
args
CorpNum : 팝빌회원 사업자번호
ItemCode : 명세서 종류 코드
[121 - 거래명세서], [122 - 청구서], [123 - 견적서],
[124 - 발주서], [125 - 입금표], [126 - 영수증]
... | Create a Python 3 function for
issuing a new item from the given CorpNum. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Cancel a single item from a given CorpNum. | Make a summary of the following Python 3 code
def cancel(self, CorpNum, ItemCode, MgtKey, Memo=None, UserID=None):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
if ItemCode == None or ItemCode == "":
raise PopbillException(-999999... | As a Python code translator, you convert algorithms and pseudocode into Python. |
def getInfo(self, CorpNum, ItemCode, MgtKey):
""" 상태/요약 정보 확인
args
CorpNum : 팝빌회원 사업자번호
ItemCode : 명세서 종류 코드
[121 - 거래명세서], [122 - 청구서], [123 - 견적서],
[124 - 발주서], [125 - 입금표], [126 - 영수증]
MgtKey : 파트너 문서관리... | Write a Python 3 function for
getting Info from Alembic. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Get the details of a particular item in a particular CorpNum. | Given the following Python 3 function, write the documentation
def getDetailInfo(self, CorpNum, ItemCode, MgtKey):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
if ItemCode == None or ItemCode == "":
raise PopbillException(-99999999... | As a Python code composer, you craft elegant and concise scripts. |
def attachFile(self, CorpNum, ItemCode, MgtKey, FilePath, UserID=None):
""" 파일 첨부
args
CorpNum : 팝빌회원 사업자번호
ItemCode : 명세서 종류 코드
[121 - 거래명세서], [122 - 청구서], [123 - 견적서],
[124 - 발주서], [125 - 입금표], [126 - 영수증]
... | How would you implement a function in Python 3 that
attaches File to CorpNum | You are a Python code architect, reviewing and designing scalable and efficient code |
def deleteFile(self, CorpNum, ItemCode, MgtKey, FileID, UserID=None):
""" 첨부파일 삭제
args
CorpNum : 팝빌회원 사업자번호
ItemCode : 명세서 종류 코드
[121 - 거래명세서], [122 - 청구서], [123 - 견적서],
[124 - 발주서], [125 - 입금표], [126 - 영수증]
... | Implement a function in Python 3 to
delete a file from the given CorpNum and MgtKey. | You are a Python code generator, capable of creating scripts from specifications. |
인쇄 URL 확인 확인 | Given the following Python 3 function, write the documentation
def getMassPrintURL(self, CorpNum, ItemCode, MgtKeyList, UserID=None):
if MgtKeyList == None:
raise PopbillException(-99999999, "관리번호 배열이 입력되지 않았습니다.")
if ItemCode == None or ItemCode == "":
raise PopbillException... | As a python code expert, you are capable of creating scripts from specifications. |
A method to attach a statement to a CorpNum. | How would you explain what the following Python 3 function does
def attachStatement(self, CorpNum, ItemCode, MgtKey, SubItemCode, SubMgtKey, UserID=None):
if MgtKey == None or MgtKey == "":
raise PopbillException(-99999999, "관리번호가 입력되지 않았습니다.")
if ItemCode == None or ItemCode == "":
... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Processes an article and adds the appropriate spine items to the internal spine list. | Can you generate the documentation for the following Python 3 function
def process(self, article):
if self.article is not None and not self.collection:
log.warning('Could not process additional article. Package only \
handles one article unless collection mode is set.')
return False
... | As a Python code composer, you craft elegant and concise scripts. |
Handles the acquisition of metadata for both collection mode and single mode. | How would you explain what the following Python 3 function does
def acquire_metadata(self):
#For space economy
publisher = self.article.publisher
if self.collection: # collection mode metadata gathering
pass
else: # single mode metadata gathering
self.pub_id = ... | As a python code expert, you are capable of creating scripts from specifications. |
Returns an iterator over the files in a location which yields item elements that can be inserted into the package manifest. | Explain what the following Python 3 code does
def file_manifest(self, location):
#Maps file extensions to mimetypes
mimetypes = {'.jpg': 'image/jpeg',
'.jpeg': 'image/jpeg',
'.xml': 'application/xhtml+xml',
'.png': 'image/png',
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def get_contrib_names(self, contrib):
"""
Returns an appropriate Name and File-As-Name for a contrib element.
This code was refactored out of nav_contributors and
package_contributors to provide a single definition point for a common
job. This is a useful utility that may be wel... | Write a Python 3 script for
returning an appropriate Name and File - As - Name for a contrib element. | You are a Python code architect, reviewing and designing scalable and efficient code |
def package_description(self):
"""
Given an Article class instance, this is responsible for returning an
article description. For this method I have taken the approach of
serializing the article's first abstract, if it has one. This results
in 0 or 1 descriptions per article.
... | Can you implement a function in Python 3 that
returns the article description for the current article. | As a Python code composer, you craft elegant and concise scripts. |
Makes the Article Title for the Heading. | Can you tell what is the following Python 3 function doing
def heading_title(self):
art_title = self.article.root.xpath('./front/article-meta/title-group/article-title')[0]
article_title = deepcopy(art_title)
article_title.tag = 'h1'
article_title.attrib['id'] = 'title'
article_t... | As a Python code analyst, you investigate and solve complex coding mysteries |
Constructs the Authors element for the Heading element. This should display the Heading element directly after the Article Title. This should display the Heading element directly after the Article Title. | Can you generate the documentation for the following Python 3 function
def make_heading_authors(self, authors):
author_element = etree.Element('h3', {'class': 'authors'})
#Construct content for the author element
first = True
for author in authors:
if first:
f... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Makes the content for the Author Affiliations element displays after the Heading. | Can you generate a brief explanation for the following Python 3 code
def make_heading_affiliations(self, heading_div):
#Get all of the aff element tuples from the metadata
affs = self.article.root.xpath('./front/article-meta/aff')
#Create a list of all those pertaining to the authors
aut... | You are a Python code analyst, evaluating scripts for potential improvements. |
This method creates the headings for all abstracts in the article. | Can you tell what is the following Python 3 function doing
def make_heading_abstracts(self, heading_div):
for abstract in self.article.root.xpath('./front/article-meta/abstract'):
#Make a copy of the abstract
abstract_copy = deepcopy(abstract)
abstract_copy.tag = 'div'
... | You are a Python code generator, capable of creating scripts from specifications. |
def make_article_info(self):
"""
The Article Info contains the (self) Citation, Editors, Dates,
Copyright, Funding Statement, Competing Interests Statement,
Correspondence, and Footnotes. Maybe more...
This content follows the Heading and precedes the Main segment in the
... | Create a Python 3 function to
create the Article Info element for the current article. | You are a Python code analyst, evaluating scripts for potential improvements. |
def make_article_info_citation(self):
"""
Creates a self citation node for the ArticleInfo of the article.
This method uses code from this page as a reference implementation:
https://github.com/PLOS/ambra/blob/master/base/src/main/resources/articleTransform-v3.xsl
"""
ci... | Can you create a Python 3 function that
creates a self citation node for the ArticleInfo of the article. | As a Python code translator, you convert algorithms and pseudocode into Python. |
Makes the section containing important dates for the article. | Explain what the following Python 3 code does
def make_article_info_dates(self):
dates_div = etree.Element('div', {'id': 'article-dates'})
d = './front/article-meta/history/date'
received = self.article.root.xpath(d + "[@date-type='received']")
accepted = self.article.root.xpath(d + "[@... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Creates the element for declaring Funding in the article info. | Can you generate a brief explanation for the following Python 3 code
def make_article_info_funding(self, article_info_div):
funding_group = self.article.root.xpath('./front/article-meta/funding-group')
if funding_group:
funding_div = etree.SubElement(article_info_div,
... | You are a Python code architect, reviewing and designing scalable and efficient code |
Creates the element for declaring competing interests in the article. | Here you have a function in Python 3, explain what it does
def make_article_info_competing_interests(self, article_info_div):
#Check for author-notes
con_expr = "./front/article-meta/author-notes/fn[@fn-type='conflict']"
conflict = self.article.root.xpath(con_expr)
if not conflict:
... | As a Python code analyst, you investigate and solve complex coding mysteries |
def make_article_info_correspondences(self, article_info_div):
"""
Articles generally provide a first contact, typically an email address
for one of the authors. This will supply that content.
"""
corresps = self.article.root.xpath('./front/article-meta/author-notes/corresp')
... | How would you implement a function in Python 3 that
adds the corresponding articles to the article_info_div. | As a python code expert, you are capable of creating scripts from specifications. |
This will create the other footnotes in the article info div. | Can you generate a brief explanation for the following Python 3 code
def make_article_info_footnotes_other(self, article_info_div):
other_fn_expr = "./back/fn-group/fn[@fn-type='other']"
other_fns = self.article.root.xpath(other_fn_expr)
if other_fns:
other_fn_div = etree.SubElement(... | You are a Python code analyst, evaluating scripts for potential improvements. |
Move anyboxed - text elements over to the receiving element. | Can you tell what is the following Python 3 function doing
def move_back_boxed_texts(self):
body = self.main.getroot().find('body')
back = self.article.root.find('back')
if back is None:
return
boxed_texts = back.xpath('.//boxed-text')
for boxed_text in boxed_texts:
... | You are a Python code analyst, evaluating scripts for potential improvements. |
def make_back_acknowledgments(self):
"""
The <ack> is an important piece of back matter information, and will be
including immediately after the main text.
This element should only occur once, optionally, for PLoS, if a need
becomes known, then multiple instances may be supporte... | Write a Python 3 function for
making the back - acks element. | As a python code expert, you are capable of creating scripts from specifications. |
Glossaries are a fairly common item in papers for PLoS, but it also
seems that they are rarely incorporated into the PLoS web-site or PDF
formats. They are included in the ePub output however because they are
helpful and because we can. | Make a summary of the following Python 3 code
def make_back_glossary(self, body):
for glossary in self.article.root.xpath('./back/glossary'):
gloss_copy = deepcopy(glossary)
gloss_copy.tag = 'div'
gloss_copy.attrib['class'] = 'back-glossary'
body.append(gloss_copy... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Make back - notes elements. | Can you generate the documentation for the following Python 3 function
def make_back_notes(self, body):
for notes in self.article.root.xpath('./back/notes'):
notes_sec = deepcopy(notes.find('sec'))
notes_sec.tag = 'div'
notes_sec.attrib['class'] = 'back-notes'
bod... | You are a Python code generator, capable of creating scripts from specifications. |
def convert_disp_formula_elements(self):
"""
<disp-formula> elements must be converted to conforming elements
"""
for disp in self.main.getroot().findall('.//disp-formula'):
#find label element
label_el = disp.find('label')
graphic_el = disp.find('grap... | Create a Python 3 function to
convert the disp - formula elements to conforming elements | You are a Python code architect, reviewing and designing scalable and efficient code |
def convert_inline_formula_elements(self):
"""
<inline-formula> elements must be converted to be conforming
These elements may contain <inline-graphic> elements, textual content,
or both.
"""
for inline in self.main.getroot().findall('.//inline-formula'):
#in... | Write a Python 3 script to
convert inline - formula elements to the corresponding image elements. | As a Python code analyst, you investigate and solve complex coding mysteries |
Convert disp - quote elements to divs. | Can you tell what is the following Python 3 function doing
def convert_disp_quote_elements(self):
for disp_quote in self.main.getroot().findall('.//disp-quote'):
if disp_quote.getparent().tag == 'p':
elevate_element(disp_quote)
disp_quote.tag = 'div'
disp_quot... | As a Python code composer, you craft elegant and concise scripts. |
Convert all the boxed - text elements in the main XML file into a single boxed - text element. | Can you generate a brief explanation for the following Python 3 code
def convert_boxed_text_elements(self):
for boxed_text in self.main.getroot().findall('.//boxed-text'):
sec_el = boxed_text.find('sec')
if sec_el is not None:
sec_el.tag = 'div'
title = se... | As a python code expert, you are capable of creating scripts from specifications. |
def convert_supplementary_material_elements(self):
"""
Supplementary material are not, nor are they generally expected to be,
packaged into the epub file. Though this is a technical possibility,
and certain epub reading systems (such as those run on a PC) might be
reasonably capa... | Write a Python 3 script to
convert supplementary material elements into a div element. | You are a Python code analyst, evaluating scripts for potential improvements. |
This function will render a formatted URL for accessing the PLoS serverSingleRepresentation of an object. | Can you generate a brief explanation for the following Python 3 code
def fetch_single_representation(self, item_xlink_href):
#A dict of URLs for PLoS subjournals
journal_urls = {'pgen': 'http://www.plosgenetics.org/article/{0}',
'pcbi': 'http://www.ploscompbiol.org/article/{0}',
... | As a Python code analyst, you investigate and solve complex coding mysteries |
Converts the JPTS 3. 0 <fig > elements to EPUB 3. 0 <img > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0 <img > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0 <fig > elements to EPUB 3. 0. | Here you have a function in Python 3, explain what it does
def convert_fig_elements(self):
for fig in self.main.getroot().findall('.//fig'):
if fig.getparent().tag == 'p':
elevate_element(fig)
for fig in self.main.getroot().findall('.//fig'):
#self.convert_fn_elem... | You are a Python code analyst, evaluating scripts for potential improvements. |
Convert the verse - group elements into italicized lines. | How would you explain what the following Python 3 function does
def convert_verse_group_elements(self):
for verse_group in self.main.getroot().findall('.//verse-group'):
#Find some possible sub elements for the heading
label = verse_group.find('label')
title = verse_group.fin... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Convert all fn elements in the main text body into a list of nparrays. | Make a summary of the following Python 3 code
def convert_fn_elements(self):
for footnote in self.main.getroot().findall('.//fn'):
#Use only the first paragraph
paragraph = footnote.find('p')
#If no paragraph, move on
if paragraph is None:
remove(f... | As a Python code translator, you convert algorithms and pseudocode into Python. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.