repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
pmacosta/pcsv | pcsv/dsort.py | dsort | def dsort(fname, order, has_header=True, frow=0, ofname=None):
r"""
Sort file data.
:param fname: Name of the comma-separated values file to sort
:type fname: FileNameExists_
:param order: Sort order
:type order: :ref:`CsvColFilter`
:param has_header: Flag that indicates whether the com... | python | def dsort(fname, order, has_header=True, frow=0, ofname=None):
r"""
Sort file data.
:param fname: Name of the comma-separated values file to sort
:type fname: FileNameExists_
:param order: Sort order
:type order: :ref:`CsvColFilter`
:param has_header: Flag that indicates whether the com... | [
"def",
"dsort",
"(",
"fname",
",",
"order",
",",
"has_header",
"=",
"True",
",",
"frow",
"=",
"0",
",",
"ofname",
"=",
"None",
")",
":",
"ofname",
"=",
"fname",
"if",
"ofname",
"is",
"None",
"else",
"ofname",
"obj",
"=",
"CsvFile",
"(",
"fname",
"=... | r"""
Sort file data.
:param fname: Name of the comma-separated values file to sort
:type fname: FileNameExists_
:param order: Sort order
:type order: :ref:`CsvColFilter`
:param has_header: Flag that indicates whether the comma-separated
values file to sort has column ... | [
"r",
"Sort",
"file",
"data",
"."
] | cd1588c19b0cd58c38bc672e396db940f88ffbd7 | https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/dsort.py#L37-L93 | train |
bachya/pyflunearyou | example.py | main | async def main() -> None:
"""Create the aiohttp session and run the example."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as websession:
try:
# Create a client:
client = Client(websession)
# Get user data for the client's latitude/longitu... | python | async def main() -> None:
"""Create the aiohttp session and run the example."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as websession:
try:
# Create a client:
client = Client(websession)
# Get user data for the client's latitude/longitu... | [
"async",
"def",
"main",
"(",
")",
"->",
"None",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
")",
"async",
"with",
"ClientSession",
"(",
")",
"as",
"websession",
":",
"try",
":",
"# Create a client:",
"client",
"=",
"Cli... | Create the aiohttp session and run the example. | [
"Create",
"the",
"aiohttp",
"session",
"and",
"run",
"the",
"example",
"."
] | 16a2f839c8df851e925e010a6b5c5708386febac | https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/example.py#L18-L50 | train |
osilkin98/PyBRY | pybry/lbryd_api.py | LbryApi.call | def call(cls, method, params=None, timeout=600):
""" Makes a Call to the LBRY API
:param str method: Method to call from the LBRY API. See the full list of methods at
https://lbryio.github.io/lbry/cli/
:param dict params: Parameters to give the method selected
:param float time... | python | def call(cls, method, params=None, timeout=600):
""" Makes a Call to the LBRY API
:param str method: Method to call from the LBRY API. See the full list of methods at
https://lbryio.github.io/lbry/cli/
:param dict params: Parameters to give the method selected
:param float time... | [
"def",
"call",
"(",
"cls",
",",
"method",
",",
"params",
"=",
"None",
",",
"timeout",
"=",
"600",
")",
":",
"params",
"=",
"[",
"]",
"if",
"params",
"is",
"None",
"else",
"params",
"return",
"cls",
".",
"make_request",
"(",
"SERVER_ADDRESS",
",",
"me... | Makes a Call to the LBRY API
:param str method: Method to call from the LBRY API. See the full list of methods at
https://lbryio.github.io/lbry/cli/
:param dict params: Parameters to give the method selected
:param float timeout: The number of seconds to wait for a connection until we ... | [
"Makes",
"a",
"Call",
"to",
"the",
"LBRY",
"API"
] | af86805a8077916f72f3fe980943d4cd741e61f0 | https://github.com/osilkin98/PyBRY/blob/af86805a8077916f72f3fe980943d4cd741e61f0/pybry/lbryd_api.py#L14-L28 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.getJobState | def getJobState(self, CorpNum, JobID, UserID=None):
""" 수집 상태 확인
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
UserID : 팝빌회원 아이디
return
수집 상태 정보
raise
PopbillException
"""
if JobID == No... | python | def getJobState(self, CorpNum, JobID, UserID=None):
""" 수집 상태 확인
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
UserID : 팝빌회원 아이디
return
수집 상태 정보
raise
PopbillException
"""
if JobID == No... | [
"def",
"getJobState",
"(",
"self",
",",
"CorpNum",
",",
"JobID",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"JobID",
"==",
"None",
"or",
"len",
"(",
"JobID",
")",
"!=",
"18",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"작업아이디(jobID)... | 수집 상태 확인
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
UserID : 팝빌회원 아이디
return
수집 상태 정보
raise
PopbillException | [
"수집",
"상태",
"확인",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"JobID",
":",
"작업아이디",
"UserID",
":",
"팝빌회원",
"아이디",
"return",
"수집",
"상태",
"정보",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L71-L85 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.search | def search(self, CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDType, TaxRegIDYN, TaxRegID, Page, PerPage,
Order, UserID=None):
""" 수집 결과 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
... | python | def search(self, CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDType, TaxRegIDYN, TaxRegID, Page, PerPage,
Order, UserID=None):
""" 수집 결과 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
... | [
"def",
"search",
"(",
"self",
",",
"CorpNum",
",",
"JobID",
",",
"Type",
",",
"TaxType",
",",
"PurposeType",
",",
"TaxRegIDType",
",",
"TaxRegIDYN",
",",
"TaxRegID",
",",
"Page",
",",
"PerPage",
",",
"Order",
",",
"UserID",
"=",
"None",
")",
":",
"if",... | 수집 결과 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
TaxType : 과세형태 배열, T-과세, N-면세, Z-영세
PurposeType : 영수/청구, R-영수, C-청구, N-없음
TaxRegIDType : 종사업장번호 사업자유형, S-공급자, B-공급받는자, T-수... | [
"수집",
"결과",
"조회",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"JobID",
":",
"작업아이디",
"Type",
":",
"문서형태",
"배열",
"N",
"-",
"일반전자세금계산서",
"M",
"-",
"수정전자세금계산서",
"TaxType",
":",
"과세형태",
"배열",
"T",
"-",
"과세",
"N",
"-",
"면세",
"Z",
"-",
"영세",
"PurposeType",
... | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L100-L137 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.summary | def summary(self, CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDType, TaxRegIDYN, TaxRegID, UserID=None):
""" 수집 결과 요약정보 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
TaxType : 과세형태 배열, T-과세, ... | python | def summary(self, CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDType, TaxRegIDYN, TaxRegID, UserID=None):
""" 수집 결과 요약정보 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
TaxType : 과세형태 배열, T-과세, ... | [
"def",
"summary",
"(",
"self",
",",
"CorpNum",
",",
"JobID",
",",
"Type",
",",
"TaxType",
",",
"PurposeType",
",",
"TaxRegIDType",
",",
"TaxRegIDYN",
",",
"TaxRegID",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"JobID",
"==",
"None",
"or",
"len",
"(",
... | 수집 결과 요약정보 조회
args
CorpNum : 팝빌회원 사업자번호
JobID : 작업아이디
Type : 문서형태 배열, N-일반전자세금계산서, M-수정전자세금계산서
TaxType : 과세형태 배열, T-과세, N-면세, Z-영세
PurposeType : 영수/청구, R-영수, C-청구, N-없음
TaxRegIDType : 종사업장번호 사업자유형, S-공급자, B-공급받는자... | [
"수집",
"결과",
"요약정보",
"조회",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"JobID",
":",
"작업아이디",
"Type",
":",
"문서형태",
"배열",
"N",
"-",
"일반전자세금계산서",
"M",
"-",
"수정전자세금계산서",
"TaxType",
":",
"과세형태",
"배열",
"T",
"-",
"과세",
"N",
"-",
"면세",
"Z",
"-",
"영세",
"Purp... | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L139-L169 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.getTaxinvoice | def getTaxinvoice(self, CorpNum, NTSConfirmNum, UserID=None):
""" 전자세금계산서 상세정보 확인
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException
... | python | def getTaxinvoice(self, CorpNum, NTSConfirmNum, UserID=None):
""" 전자세금계산서 상세정보 확인
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException
... | [
"def",
"getTaxinvoice",
"(",
"self",
",",
"CorpNum",
",",
"NTSConfirmNum",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"NTSConfirmNum",
"==",
"None",
"or",
"len",
"(",
"NTSConfirmNum",
")",
"!=",
"24",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999"... | 전자세금계산서 상세정보 확인
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException | [
"전자세금계산서",
"상세정보",
"확인",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"NTSConfirmNum",
":",
"국세청",
"승인번호",
"UserID",
":",
"팝빌회원",
"아이디",
"return",
"전자세금계산서",
"정보객체",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L171-L185 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.getXML | def getXML(self, CorpNum, NTSConfirmNum, UserID=None):
""" 전자세금계산서 상세정보 확인 - XML
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException
... | python | def getXML(self, CorpNum, NTSConfirmNum, UserID=None):
""" 전자세금계산서 상세정보 확인 - XML
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException
... | [
"def",
"getXML",
"(",
"self",
",",
"CorpNum",
",",
"NTSConfirmNum",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"NTSConfirmNum",
"==",
"None",
"or",
"len",
"(",
"NTSConfirmNum",
")",
"!=",
"24",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
","... | 전자세금계산서 상세정보 확인 - XML
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인번호
UserID : 팝빌회원 아이디
return
전자세금계산서 정보객체
raise
PopbillException | [
"전자세금계산서",
"상세정보",
"확인",
"-",
"XML",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"NTSConfirmNum",
":",
"국세청",
"승인번호",
"UserID",
":",
"팝빌회원",
"아이디",
"return",
"전자세금계산서",
"정보객체",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L187-L201 | train |
linkhub-sdk/popbill.py | popbill/htTaxinvoiceService.py | HTTaxinvoiceService.getPopUpURL | def getPopUpURL(self, CorpNum, NTSConfirmNum, UserID=None):
""" 홈택스 전자세금계산서 보기 팝업 URL
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인 번호
UserID : 팝빌회원 아이디
return
전자세금계산서 보기 팝업 URL 반환
raise
Popbil... | python | def getPopUpURL(self, CorpNum, NTSConfirmNum, UserID=None):
""" 홈택스 전자세금계산서 보기 팝업 URL
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인 번호
UserID : 팝빌회원 아이디
return
전자세금계산서 보기 팝업 URL 반환
raise
Popbil... | [
"def",
"getPopUpURL",
"(",
"self",
",",
"CorpNum",
",",
"NTSConfirmNum",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"NTSConfirmNum",
"==",
"None",
"or",
"len",
"(",
"NTSConfirmNum",
")",
"!=",
"24",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
... | 홈택스 전자세금계산서 보기 팝업 URL
args
CorpNum : 팝빌회원 사업자번호
NTSConfirmNum : 국세청 승인 번호
UserID : 팝빌회원 아이디
return
전자세금계산서 보기 팝업 URL 반환
raise
PopbillException | [
"홈택스",
"전자세금계산서",
"보기",
"팝업",
"URL",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"NTSConfirmNum",
":",
"국세청",
"승인",
"번호",
"UserID",
":",
"팝빌회원",
"아이디",
"return",
"전자세금계산서",
"보기",
"팝업",
"URL",
"반환",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htTaxinvoiceService.py#L252-L267 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/__init__.py | Publisher.make_document | def make_document(self, titlestring):
"""
This method may be used to create a new document for writing as xml
to the OPS subdirectory of the ePub structure.
"""
#root = etree.XML('''<?xml version="1.0"?>\
#<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/... | python | def make_document(self, titlestring):
"""
This method may be used to create a new document for writing as xml
to the OPS subdirectory of the ePub structure.
"""
#root = etree.XML('''<?xml version="1.0"?>\
#<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/... | [
"def",
"make_document",
"(",
"self",
",",
"titlestring",
")",
":",
"#root = etree.XML('''<?xml version=\"1.0\"?>\\",
"#<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'>\\",
"#<html xml:lang=\"en-US\" xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:o... | This method may be used to create a new document for writing as xml
to the OPS subdirectory of the ePub structure. | [
"This",
"method",
"may",
"be",
"used",
"to",
"create",
"a",
"new",
"document",
"for",
"writing",
"as",
"xml",
"to",
"the",
"OPS",
"subdirectory",
"of",
"the",
"ePub",
"structure",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/__init__.py#L196-L224 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/__init__.py | Publisher.write_document | def write_document(self, name, document):
"""
This function will write a document to an XML file.
"""
with open(name, 'wb') as out:
out.write(etree.tostring(document,
encoding='utf-8',
pretty_print=True... | python | def write_document(self, name, document):
"""
This function will write a document to an XML file.
"""
with open(name, 'wb') as out:
out.write(etree.tostring(document,
encoding='utf-8',
pretty_print=True... | [
"def",
"write_document",
"(",
"self",
",",
"name",
",",
"document",
")",
":",
"with",
"open",
"(",
"name",
",",
"'wb'",
")",
"as",
"out",
":",
"out",
".",
"write",
"(",
"etree",
".",
"tostring",
"(",
"document",
",",
"encoding",
"=",
"'utf-8'",
",",
... | This function will write a document to an XML file. | [
"This",
"function",
"will",
"write",
"a",
"document",
"to",
"an",
"XML",
"file",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/__init__.py#L281-L288 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/__init__.py | Publisher.format_date_string | def format_date_string(self, date_tuple):
"""
Receives a date_tuple object, and outputs a string
for placement in the article content.
"""
months = ['', 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',... | python | def format_date_string(self, date_tuple):
"""
Receives a date_tuple object, and outputs a string
for placement in the article content.
"""
months = ['', 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',... | [
"def",
"format_date_string",
"(",
"self",
",",
"date_tuple",
")",
":",
"months",
"=",
"[",
"''",
",",
"'January'",
",",
"'February'",
",",
"'March'",
",",
"'April'",
",",
"'May'",
",",
"'June'",
",",
"'July'",
",",
"'August'",
",",
"'September'",
",",
"'... | Receives a date_tuple object, and outputs a string
for placement in the article content. | [
"Receives",
"a",
"date_tuple",
"object",
"and",
"outputs",
"a",
"string",
"for",
"placement",
"in",
"the",
"article",
"content",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/__init__.py#L539-L556 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/__init__.py | Publisher.has_out_of_flow_tables | def has_out_of_flow_tables(self):
"""
Returns True if the article has out-of-flow tables, indicates separate
tables document.
This method is used to indicate whether rendering this article's content
will result in the creation of out-of-flow HTML tables. This method has
... | python | def has_out_of_flow_tables(self):
"""
Returns True if the article has out-of-flow tables, indicates separate
tables document.
This method is used to indicate whether rendering this article's content
will result in the creation of out-of-flow HTML tables. This method has
... | [
"def",
"has_out_of_flow_tables",
"(",
"self",
")",
":",
"if",
"self",
".",
"article",
".",
"body",
"is",
"None",
":",
"return",
"False",
"for",
"table_wrap",
"in",
"self",
".",
"article",
".",
"body",
".",
"findall",
"(",
"'.//table-wrap'",
")",
":",
"gr... | Returns True if the article has out-of-flow tables, indicates separate
tables document.
This method is used to indicate whether rendering this article's content
will result in the creation of out-of-flow HTML tables. This method has
a base class implementation representing a common logi... | [
"Returns",
"True",
"if",
"the",
"article",
"has",
"out",
"-",
"of",
"-",
"flow",
"tables",
"indicates",
"separate",
"tables",
"document",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/__init__.py#L686-L711 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/navigation/__init__.py | Navigation.process | def process(self, article):
"""
Ingests an Article to create navigation structures and parse global
metadata.
"""
if self.article is not None and not self.collection:
log.warning('Could not process additional article. Navigation only \
handles one article unless colle... | python | def process(self, article):
"""
Ingests an Article to create navigation structures and parse global
metadata.
"""
if self.article is not None and not self.collection:
log.warning('Could not process additional article. Navigation only \
handles one article unless colle... | [
"def",
"process",
"(",
"self",
",",
"article",
")",
":",
"if",
"self",
".",
"article",
"is",
"not",
"None",
"and",
"not",
"self",
".",
"collection",
":",
"log",
".",
"warning",
"(",
"'Could not process additional article. Navigation only \\\nhandles one article unle... | Ingests an Article to create navigation structures and parse global
metadata. | [
"Ingests",
"an",
"Article",
"to",
"create",
"navigation",
"structures",
"and",
"parse",
"global",
"metadata",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/navigation/__init__.py#L63-L88 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/navigation/__init__.py | Navigation.map_navigation | def map_navigation(self):
"""
This is a wrapper for depth-first recursive analysis of the article
"""
#All articles should have titles
title_id = 'titlepage-{0}'.format(self.article_doi)
title_label = self.article.publisher.nav_title()
title_source = 'main.{0}.xht... | python | def map_navigation(self):
"""
This is a wrapper for depth-first recursive analysis of the article
"""
#All articles should have titles
title_id = 'titlepage-{0}'.format(self.article_doi)
title_label = self.article.publisher.nav_title()
title_source = 'main.{0}.xht... | [
"def",
"map_navigation",
"(",
"self",
")",
":",
"#All articles should have titles",
"title_id",
"=",
"'titlepage-{0}'",
".",
"format",
"(",
"self",
".",
"article_doi",
")",
"title_label",
"=",
"self",
".",
"article",
".",
"publisher",
".",
"nav_title",
"(",
")",... | This is a wrapper for depth-first recursive analysis of the article | [
"This",
"is",
"a",
"wrapper",
"for",
"depth",
"-",
"first",
"recursive",
"analysis",
"of",
"the",
"article"
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/navigation/__init__.py#L90-L121 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/navigation/__init__.py | Navigation.recursive_article_navmap | def recursive_article_navmap(self, src_element, depth=0, first=True):
"""
This function recursively traverses the content of an input article to
add the correct elements to the NCX file's navMap and Lists.
"""
if depth > self.nav_depth:
self.nav_depth = depth
... | python | def recursive_article_navmap(self, src_element, depth=0, first=True):
"""
This function recursively traverses the content of an input article to
add the correct elements to the NCX file's navMap and Lists.
"""
if depth > self.nav_depth:
self.nav_depth = depth
... | [
"def",
"recursive_article_navmap",
"(",
"self",
",",
"src_element",
",",
"depth",
"=",
"0",
",",
"first",
"=",
"True",
")",
":",
"if",
"depth",
">",
"self",
".",
"nav_depth",
":",
"self",
".",
"nav_depth",
"=",
"depth",
"navpoints",
"=",
"[",
"]",
"tag... | This function recursively traverses the content of an input article to
add the correct elements to the NCX file's navMap and Lists. | [
"This",
"function",
"recursively",
"traverses",
"the",
"content",
"of",
"an",
"input",
"article",
"to",
"add",
"the",
"correct",
"elements",
"to",
"the",
"NCX",
"file",
"s",
"navMap",
"and",
"Lists",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/navigation/__init__.py#L123-L183 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/navigation/__init__.py | Navigation.render_EPUB2 | def render_EPUB2(self, location):
"""
Creates the NCX specified file for EPUB2
"""
def make_navlabel(text):
"""
Creates and returns a navLabel element with the supplied text.
"""
navlabel = etree.Element('navLabel')
navlabel_te... | python | def render_EPUB2(self, location):
"""
Creates the NCX specified file for EPUB2
"""
def make_navlabel(text):
"""
Creates and returns a navLabel element with the supplied text.
"""
navlabel = etree.Element('navLabel')
navlabel_te... | [
"def",
"render_EPUB2",
"(",
"self",
",",
"location",
")",
":",
"def",
"make_navlabel",
"(",
"text",
")",
":",
"\"\"\"\n Creates and returns a navLabel element with the supplied text.\n \"\"\"",
"navlabel",
"=",
"etree",
".",
"Element",
"(",
"'navLabel'... | Creates the NCX specified file for EPUB2 | [
"Creates",
"the",
"NCX",
"specified",
"file",
"for",
"EPUB2"
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/navigation/__init__.py#L185-L266 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcGauss1D | def funcGauss1D(x, mu, sig):
""" Create 1D Gaussian. Source:
http://mathworld.wolfram.com/GaussianFunction.html
"""
arrOut = np.exp(-np.power((x - mu)/sig, 2.)/2)
# normalize
# arrOut = arrOut/(np.sqrt(2.*np.pi)*sig)
# normalize (laternative)
arrOut = arrOut/np.sum(arrOut)
return arrO... | python | def funcGauss1D(x, mu, sig):
""" Create 1D Gaussian. Source:
http://mathworld.wolfram.com/GaussianFunction.html
"""
arrOut = np.exp(-np.power((x - mu)/sig, 2.)/2)
# normalize
# arrOut = arrOut/(np.sqrt(2.*np.pi)*sig)
# normalize (laternative)
arrOut = arrOut/np.sum(arrOut)
return arrO... | [
"def",
"funcGauss1D",
"(",
"x",
",",
"mu",
",",
"sig",
")",
":",
"arrOut",
"=",
"np",
".",
"exp",
"(",
"-",
"np",
".",
"power",
"(",
"(",
"x",
"-",
"mu",
")",
"/",
"sig",
",",
"2.",
")",
"/",
"2",
")",
"# normalize",
"# arrOut = arrOut/(np.sqr... | Create 1D Gaussian. Source:
http://mathworld.wolfram.com/GaussianFunction.html | [
"Create",
"1D",
"Gaussian",
".",
"Source",
":",
"http",
":",
"//",
"mathworld",
".",
"wolfram",
".",
"com",
"/",
"GaussianFunction",
".",
"html"
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L20-L29 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcGauss2D | def funcGauss2D(varSizeX, varSizeY, varPosX, varPosY, varSd):
""" Create 2D Gaussian kernel. Source:
http://mathworld.wolfram.com/GaussianFunction.html
"""
varSizeX = int(varSizeX)
varSizeY = int(varSizeY)
# aryX and aryY are in reversed order, this seems to be necessary:
aryY, aryX = sp.... | python | def funcGauss2D(varSizeX, varSizeY, varPosX, varPosY, varSd):
""" Create 2D Gaussian kernel. Source:
http://mathworld.wolfram.com/GaussianFunction.html
"""
varSizeX = int(varSizeX)
varSizeY = int(varSizeY)
# aryX and aryY are in reversed order, this seems to be necessary:
aryY, aryX = sp.... | [
"def",
"funcGauss2D",
"(",
"varSizeX",
",",
"varSizeY",
",",
"varPosX",
",",
"varPosY",
",",
"varSd",
")",
":",
"varSizeX",
"=",
"int",
"(",
"varSizeX",
")",
"varSizeY",
"=",
"int",
"(",
"varSizeY",
")",
"# aryX and aryY are in reversed order, this seems to be nec... | Create 2D Gaussian kernel. Source:
http://mathworld.wolfram.com/GaussianFunction.html | [
"Create",
"2D",
"Gaussian",
"kernel",
".",
"Source",
":",
"http",
":",
"//",
"mathworld",
".",
"wolfram",
".",
"com",
"/",
"GaussianFunction",
".",
"html"
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L33-L58 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcConvPar | def funcConvPar(aryDm,
vecHrf,
varNumVol):
"""
Function for convolution of pixel-wise 'design matrix' with HRF model.
"""
# In order to avoid an artefact at the end of the time series, we have to
# concatenate an empty array to both the design matrix and the HRF mode... | python | def funcConvPar(aryDm,
vecHrf,
varNumVol):
"""
Function for convolution of pixel-wise 'design matrix' with HRF model.
"""
# In order to avoid an artefact at the end of the time series, we have to
# concatenate an empty array to both the design matrix and the HRF mode... | [
"def",
"funcConvPar",
"(",
"aryDm",
",",
"vecHrf",
",",
"varNumVol",
")",
":",
"# In order to avoid an artefact at the end of the time series, we have to",
"# concatenate an empty array to both the design matrix and the HRF model",
"# before convolution.",
"aryDm",
"=",
"np",
".",
... | Function for convolution of pixel-wise 'design matrix' with HRF model. | [
"Function",
"for",
"convolution",
"of",
"pixel",
"-",
"wise",
"design",
"matrix",
"with",
"HRF",
"model",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L112-L131 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | simulateAR1 | def simulateAR1(n,
beta,
sigma,
c,
burnin,
varNumCNR,
varNumTP,
):
"""
Simulates an AR(1) model using the parameters beta, c, and sigma.
Returns an array with length n
n := number of time poi... | python | def simulateAR1(n,
beta,
sigma,
c,
burnin,
varNumCNR,
varNumTP,
):
"""
Simulates an AR(1) model using the parameters beta, c, and sigma.
Returns an array with length n
n := number of time poi... | [
"def",
"simulateAR1",
"(",
"n",
",",
"beta",
",",
"sigma",
",",
"c",
",",
"burnin",
",",
"varNumCNR",
",",
"varNumTP",
",",
")",
":",
"# Output array with noise time courses",
"noise",
"=",
"np",
".",
"empty",
"(",
"(",
"varNumCNR",
",",
"varNumTP",
")",
... | Simulates an AR(1) model using the parameters beta, c, and sigma.
Returns an array with length n
n := number of time points
beta := correlation weight
sigma := standard deviation of the noise, can be a vector
c := constant added to the noise, default 0
based on:
source1: https://github.com... | [
"Simulates",
"an",
"AR",
"(",
"1",
")",
"model",
"using",
"the",
"parameters",
"beta",
"c",
"and",
"sigma",
".",
"Returns",
"an",
"array",
"with",
"length",
"n"
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L149-L185 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcNrlTcMotPred | def funcNrlTcMotPred(idxPrc,
varPixX,
varPixY,
NrlMdlChunk,
varNumTP,
aryBoxCar, # aryCond
path,
varNumNrlMdls,
varNumMtDrctn,
var... | python | def funcNrlTcMotPred(idxPrc,
varPixX,
varPixY,
NrlMdlChunk,
varNumTP,
aryBoxCar, # aryCond
path,
varNumNrlMdls,
varNumMtDrctn,
var... | [
"def",
"funcNrlTcMotPred",
"(",
"idxPrc",
",",
"varPixX",
",",
"varPixY",
",",
"NrlMdlChunk",
",",
"varNumTP",
",",
"aryBoxCar",
",",
"# aryCond",
"path",
",",
"varNumNrlMdls",
",",
"varNumMtDrctn",
",",
"varPar",
",",
"queOut",
")",
":",
"# # if hd5 method i... | Function for creating neural time course models.
This function should be used to create neural models if different
predictors for every motion direction are included. | [
"Function",
"for",
"creating",
"neural",
"time",
"course",
"models",
".",
"This",
"function",
"should",
"be",
"used",
"to",
"create",
"neural",
"models",
"if",
"different",
"predictors",
"for",
"every",
"motion",
"direction",
"are",
"included",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L359-L485 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcFindPrf | def funcFindPrf(idxPrc,
aryFuncChnk,
aryPrfTc,
aryMdls,
queOut):
"""
Function for finding best pRF model for voxel time course.
This function should be used if there is only one predictor.
"""
# Number of voxels to be fitted in this c... | python | def funcFindPrf(idxPrc,
aryFuncChnk,
aryPrfTc,
aryMdls,
queOut):
"""
Function for finding best pRF model for voxel time course.
This function should be used if there is only one predictor.
"""
# Number of voxels to be fitted in this c... | [
"def",
"funcFindPrf",
"(",
"idxPrc",
",",
"aryFuncChnk",
",",
"aryPrfTc",
",",
"aryMdls",
",",
"queOut",
")",
":",
"# Number of voxels to be fitted in this chunk:",
"varNumVoxChnk",
"=",
"aryFuncChnk",
".",
"shape",
"[",
"0",
"]",
"# Number of volumes:",
"varNumVol",
... | Function for finding best pRF model for voxel time course.
This function should be used if there is only one predictor. | [
"Function",
"for",
"finding",
"best",
"pRF",
"model",
"for",
"voxel",
"time",
"course",
".",
"This",
"function",
"should",
"be",
"used",
"if",
"there",
"is",
"only",
"one",
"predictor",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L627-L817 | train |
MSchnei/pyprf_feature | pyprf_feature/simulation/pRF_functions.py | funcFindPrfMltpPrdXVal | def funcFindPrfMltpPrdXVal(idxPrc,
aryFuncChnkTrn,
aryFuncChnkTst,
aryPrfMdlsTrnConv,
aryPrfMdlsTstConv,
aryMdls,
queOut):
"""
Function for finding be... | python | def funcFindPrfMltpPrdXVal(idxPrc,
aryFuncChnkTrn,
aryFuncChnkTst,
aryPrfMdlsTrnConv,
aryPrfMdlsTstConv,
aryMdls,
queOut):
"""
Function for finding be... | [
"def",
"funcFindPrfMltpPrdXVal",
"(",
"idxPrc",
",",
"aryFuncChnkTrn",
",",
"aryFuncChnkTst",
",",
"aryPrfMdlsTrnConv",
",",
"aryPrfMdlsTstConv",
",",
"aryMdls",
",",
"queOut",
")",
":",
"# Number of voxels to be fitted in this chunk:",
"varNumVoxChnk",
"=",
"aryFuncChnkTrn... | Function for finding best pRF model for voxel time course.
This function should be used if there are several predictors. | [
"Function",
"for",
"finding",
"best",
"pRF",
"model",
"for",
"voxel",
"time",
"course",
".",
"This",
"function",
"should",
"be",
"used",
"if",
"there",
"are",
"several",
"predictors",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/simulation/pRF_functions.py#L1015-L1168 | train |
pmacosta/pcsv | pcsv/concatenate.py | concatenate | def concatenate(
fname1,
fname2,
dfilter1=None,
dfilter2=None,
has_header1=True,
has_header2=True,
frow1=0,
frow2=0,
ofname=None,
ocols=None,
):
r"""
Concatenate two comma-separated values file.
Data rows from the second file are appended at the end of the data rows
... | python | def concatenate(
fname1,
fname2,
dfilter1=None,
dfilter2=None,
has_header1=True,
has_header2=True,
frow1=0,
frow2=0,
ofname=None,
ocols=None,
):
r"""
Concatenate two comma-separated values file.
Data rows from the second file are appended at the end of the data rows
... | [
"def",
"concatenate",
"(",
"fname1",
",",
"fname2",
",",
"dfilter1",
"=",
"None",
",",
"dfilter2",
"=",
"None",
",",
"has_header1",
"=",
"True",
",",
"has_header2",
"=",
"True",
",",
"frow1",
"=",
"0",
",",
"frow2",
"=",
"0",
",",
"ofname",
"=",
"Non... | r"""
Concatenate two comma-separated values file.
Data rows from the second file are appended at the end of the data rows
from the first file
:param fname1: Name of the first comma-separated values file, the file
whose data appears first in the output file
:type fname1: FileNam... | [
"r",
"Concatenate",
"two",
"comma",
"-",
"separated",
"values",
"file",
"."
] | cd1588c19b0cd58c38bc672e396db940f88ffbd7 | https://github.com/pmacosta/pcsv/blob/cd1588c19b0cd58c38bc672e396db940f88ffbd7/pcsv/concatenate.py#L46-L179 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | move_images_to_cache | def move_images_to_cache(source, destination):
"""
Handles the movement of images to the cache. Must be helpful if it finds
that the folder for this article already exists.
"""
if os.path.isdir(destination):
log.debug('Cached images for this article already exist')
return
else:
... | python | def move_images_to_cache(source, destination):
"""
Handles the movement of images to the cache. Must be helpful if it finds
that the folder for this article already exists.
"""
if os.path.isdir(destination):
log.debug('Cached images for this article already exist')
return
else:
... | [
"def",
"move_images_to_cache",
"(",
"source",
",",
"destination",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"destination",
")",
":",
"log",
".",
"debug",
"(",
"'Cached images for this article already exist'",
")",
"return",
"else",
":",
"log",
".",... | Handles the movement of images to the cache. Must be helpful if it finds
that the folder for this article already exists. | [
"Handles",
"the",
"movement",
"of",
"images",
"to",
"the",
"cache",
".",
"Must",
"be",
"helpful",
"if",
"it",
"finds",
"that",
"the",
"folder",
"for",
"this",
"article",
"already",
"exists",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L19-L34 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | explicit_images | def explicit_images(images, image_destination, rootname, config):
"""
The method used to handle an explicitly defined image directory by the
user as a parsed argument.
"""
log.info('Explicit image directory specified: {0}'.format(images))
if '*' in images:
images = images.replace('*', ro... | python | def explicit_images(images, image_destination, rootname, config):
"""
The method used to handle an explicitly defined image directory by the
user as a parsed argument.
"""
log.info('Explicit image directory specified: {0}'.format(images))
if '*' in images:
images = images.replace('*', ro... | [
"def",
"explicit_images",
"(",
"images",
",",
"image_destination",
",",
"rootname",
",",
"config",
")",
":",
"log",
".",
"info",
"(",
"'Explicit image directory specified: {0}'",
".",
"format",
"(",
"images",
")",
")",
"if",
"'*'",
"in",
"images",
":",
"images... | The method used to handle an explicitly defined image directory by the
user as a parsed argument. | [
"The",
"method",
"used",
"to",
"handle",
"an",
"explicitly",
"defined",
"image",
"directory",
"by",
"the",
"user",
"as",
"a",
"parsed",
"argument",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L37-L55 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | input_relative_images | def input_relative_images(input_path, image_destination, rootname, config):
"""
The method used to handle Input-Relative image inclusion.
"""
log.debug('Looking for input relative images')
input_dirname = os.path.dirname(input_path)
for path in config.input_relative_images:
if '*' in pat... | python | def input_relative_images(input_path, image_destination, rootname, config):
"""
The method used to handle Input-Relative image inclusion.
"""
log.debug('Looking for input relative images')
input_dirname = os.path.dirname(input_path)
for path in config.input_relative_images:
if '*' in pat... | [
"def",
"input_relative_images",
"(",
"input_path",
",",
"image_destination",
",",
"rootname",
",",
"config",
")",
":",
"log",
".",
"debug",
"(",
"'Looking for input relative images'",
")",
"input_dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"input_path",... | The method used to handle Input-Relative image inclusion. | [
"The",
"method",
"used",
"to",
"handle",
"Input",
"-",
"Relative",
"image",
"inclusion",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L58-L73 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | image_cache | def image_cache(article_cache, img_dir):
"""
The method to be used by get_images() for copying images out of the cache.
"""
log.debug('Looking for image directory in the cache')
if os.path.isdir(article_cache):
log.info('Cached image directory found: {0}'.format(article_cache))
shuti... | python | def image_cache(article_cache, img_dir):
"""
The method to be used by get_images() for copying images out of the cache.
"""
log.debug('Looking for image directory in the cache')
if os.path.isdir(article_cache):
log.info('Cached image directory found: {0}'.format(article_cache))
shuti... | [
"def",
"image_cache",
"(",
"article_cache",
",",
"img_dir",
")",
":",
"log",
".",
"debug",
"(",
"'Looking for image directory in the cache'",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"article_cache",
")",
":",
"log",
".",
"info",
"(",
"'Cached image di... | The method to be used by get_images() for copying images out of the cache. | [
"The",
"method",
"to",
"be",
"used",
"by",
"get_images",
"()",
"for",
"copying",
"images",
"out",
"of",
"the",
"cache",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L76-L85 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | get_images | def get_images(output_directory, explicit, input_path, config, parsed_article):
"""
Main logic controller for the placement of images into the output directory
Controlling logic for placement of the appropriate imager files into the
EPUB directory. This function interacts with interface arguments as we... | python | def get_images(output_directory, explicit, input_path, config, parsed_article):
"""
Main logic controller for the placement of images into the output directory
Controlling logic for placement of the appropriate imager files into the
EPUB directory. This function interacts with interface arguments as we... | [
"def",
"get_images",
"(",
"output_directory",
",",
"explicit",
",",
"input_path",
",",
"config",
",",
"parsed_article",
")",
":",
"#Split the DOI",
"journal_doi",
",",
"article_doi",
"=",
"parsed_article",
".",
"doi",
".",
"split",
"(",
"'/'",
")",
"log",
".",... | Main logic controller for the placement of images into the output directory
Controlling logic for placement of the appropriate imager files into the
EPUB directory. This function interacts with interface arguments as well as
the local installation config.py file. These may change behavior of this
funct... | [
"Main",
"logic",
"controller",
"for",
"the",
"placement",
"of",
"images",
"into",
"the",
"output",
"directory"
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L88-L168 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | make_image_cache | def make_image_cache(img_cache):
"""
Initiates the image cache if it does not exist
"""
log.info('Initiating the image cache at {0}'.format(img_cache))
if not os.path.isdir(img_cache):
utils.mkdir_p(img_cache)
utils.mkdir_p(os.path.join(img_cache, '10.1371'))
utils.mkdir_p(os... | python | def make_image_cache(img_cache):
"""
Initiates the image cache if it does not exist
"""
log.info('Initiating the image cache at {0}'.format(img_cache))
if not os.path.isdir(img_cache):
utils.mkdir_p(img_cache)
utils.mkdir_p(os.path.join(img_cache, '10.1371'))
utils.mkdir_p(os... | [
"def",
"make_image_cache",
"(",
"img_cache",
")",
":",
"log",
".",
"info",
"(",
"'Initiating the image cache at {0}'",
".",
"format",
"(",
"img_cache",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"img_cache",
")",
":",
"utils",
".",
"mkdir... | Initiates the image cache if it does not exist | [
"Initiates",
"the",
"image",
"cache",
"if",
"it",
"does",
"not",
"exist"
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L171-L179 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | fetch_frontiers_images | def fetch_frontiers_images(doi, output_dir):
"""
Fetch the images from Frontiers' website. This method may fail to properly
locate all the images and should be avoided if the files can be accessed
locally. Downloading the images to an appropriate directory in the cache,
or to a directory specified b... | python | def fetch_frontiers_images(doi, output_dir):
"""
Fetch the images from Frontiers' website. This method may fail to properly
locate all the images and should be avoided if the files can be accessed
locally. Downloading the images to an appropriate directory in the cache,
or to a directory specified b... | [
"def",
"fetch_frontiers_images",
"(",
"doi",
",",
"output_dir",
")",
":",
"log",
".",
"info",
"(",
"'Fetching Frontiers images'",
")",
"log",
".",
"warning",
"(",
"'This method may fail to locate all images.'",
")",
"def",
"download_image",
"(",
"fetch",
",",
"img_f... | Fetch the images from Frontiers' website. This method may fail to properly
locate all the images and should be avoided if the files can be accessed
locally. Downloading the images to an appropriate directory in the cache,
or to a directory specified by passed argument are the preferred means to
access i... | [
"Fetch",
"the",
"images",
"from",
"Frontiers",
"website",
".",
"This",
"method",
"may",
"fail",
"to",
"properly",
"locate",
"all",
"the",
"images",
"and",
"should",
"be",
"avoided",
"if",
"the",
"files",
"can",
"be",
"accessed",
"locally",
".",
"Downloading"... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L182-L273 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/images.py | fetch_plos_images | def fetch_plos_images(article_doi, output_dir, document):
"""
Fetch the images for a PLoS article from the internet.
PLoS images are known through the inspection of <graphic> and
<inline-graphic> elements. The information in these tags are then parsed
into appropriate URLs for downloading.
"""
... | python | def fetch_plos_images(article_doi, output_dir, document):
"""
Fetch the images for a PLoS article from the internet.
PLoS images are known through the inspection of <graphic> and
<inline-graphic> elements. The information in these tags are then parsed
into appropriate URLs for downloading.
"""
... | [
"def",
"fetch_plos_images",
"(",
"article_doi",
",",
"output_dir",
",",
"document",
")",
":",
"log",
".",
"info",
"(",
"'Processing images for {0}...'",
".",
"format",
"(",
"article_doi",
")",
")",
"#A dict of URLs for PLoS subjournals",
"journal_urls",
"=",
"{",
"'... | Fetch the images for a PLoS article from the internet.
PLoS images are known through the inspection of <graphic> and
<inline-graphic> elements. The information in these tags are then parsed
into appropriate URLs for downloading. | [
"Fetch",
"the",
"images",
"for",
"a",
"PLoS",
"article",
"from",
"the",
"internet",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/images.py#L276-L336 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/save_fit_tc_nii.py | save_tc_to_nii | def save_tc_to_nii(strCsvCnfg, lgcTest=False, lstRat=None, lgcMdlRsp=False,
strPathHrf=None, lgcSaveRam=False):
"""
Save empirical and fitted time courses to nii file format.
Parameters
----------
strCsvCnfg : str
Absolute file path of config file used for pRF fitting.
... | python | def save_tc_to_nii(strCsvCnfg, lgcTest=False, lstRat=None, lgcMdlRsp=False,
strPathHrf=None, lgcSaveRam=False):
"""
Save empirical and fitted time courses to nii file format.
Parameters
----------
strCsvCnfg : str
Absolute file path of config file used for pRF fitting.
... | [
"def",
"save_tc_to_nii",
"(",
"strCsvCnfg",
",",
"lgcTest",
"=",
"False",
",",
"lstRat",
"=",
"None",
",",
"lgcMdlRsp",
"=",
"False",
",",
"strPathHrf",
"=",
"None",
",",
"lgcSaveRam",
"=",
"False",
")",
":",
"# %% Load configuration settings that were used for fi... | Save empirical and fitted time courses to nii file format.
Parameters
----------
strCsvCnfg : str
Absolute file path of config file used for pRF fitting.
lgcTest : boolean
Whether this is a test (pytest). If yes, absolute path of pyprf libary
will be prepended to config file pat... | [
"Save",
"empirical",
"and",
"fitted",
"time",
"courses",
"to",
"nii",
"file",
"format",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/save_fit_tc_nii.py#L39-L292 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/pyprf_sim.py | pyprf_sim | def pyprf_sim(strPrior, strStmApr, lgcNoise=False, lgcRtnNrl=True,
lstRat=None, lgcTest=False):
"""
Simulate pRF response given pRF parameters and stimulus apertures.
Parameters
----------
strPrior : str
Absolute file path of config file used for pRF fitting.
strStmApr : s... | python | def pyprf_sim(strPrior, strStmApr, lgcNoise=False, lgcRtnNrl=True,
lstRat=None, lgcTest=False):
"""
Simulate pRF response given pRF parameters and stimulus apertures.
Parameters
----------
strPrior : str
Absolute file path of config file used for pRF fitting.
strStmApr : s... | [
"def",
"pyprf_sim",
"(",
"strPrior",
",",
"strStmApr",
",",
"lgcNoise",
"=",
"False",
",",
"lgcRtnNrl",
"=",
"True",
",",
"lstRat",
"=",
"None",
",",
"lgcTest",
"=",
"False",
")",
":",
"# %% Load configuration settings that were used for fitting",
"# Load config par... | Simulate pRF response given pRF parameters and stimulus apertures.
Parameters
----------
strPrior : str
Absolute file path of config file used for pRF fitting.
strStmApr : str
Absolute file path to stimulus aperture used in in-silico experiment.
lgcNoise : boolean
Should noi... | [
"Simulate",
"pRF",
"response",
"given",
"pRF",
"parameters",
"and",
"stimulus",
"apertures",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim.py#L35-L209 | train |
bachya/pyflunearyou | pyflunearyou/helpers/__init__.py | get_nearest_by_numeric_key | def get_nearest_by_numeric_key(data: dict, key: int) -> Any:
"""Return the dict element whose numeric key is closest to a target."""
return data.get(key, data[min(data.keys(), key=lambda k: abs(k - key))]) | python | def get_nearest_by_numeric_key(data: dict, key: int) -> Any:
"""Return the dict element whose numeric key is closest to a target."""
return data.get(key, data[min(data.keys(), key=lambda k: abs(k - key))]) | [
"def",
"get_nearest_by_numeric_key",
"(",
"data",
":",
"dict",
",",
"key",
":",
"int",
")",
"->",
"Any",
":",
"return",
"data",
".",
"get",
"(",
"key",
",",
"data",
"[",
"min",
"(",
"data",
".",
"keys",
"(",
")",
",",
"key",
"=",
"lambda",
"k",
"... | Return the dict element whose numeric key is closest to a target. | [
"Return",
"the",
"dict",
"element",
"whose",
"numeric",
"key",
"is",
"closest",
"to",
"a",
"target",
"."
] | 16a2f839c8df851e925e010a6b5c5708386febac | https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/helpers/__init__.py#L5-L7 | train |
olivier-m/rafter | rafter/blueprints.py | Blueprint.resource | def resource(self, uri, methods=frozenset({'GET'}), host=None,
strict_slashes=None, stream=False, version=None, name=None,
**kwargs):
"""
Create a blueprint resource route from a decorated function.
:param uri: endpoint at which the route will be accessible.
... | python | def resource(self, uri, methods=frozenset({'GET'}), host=None,
strict_slashes=None, stream=False, version=None, name=None,
**kwargs):
"""
Create a blueprint resource route from a decorated function.
:param uri: endpoint at which the route will be accessible.
... | [
"def",
"resource",
"(",
"self",
",",
"uri",
",",
"methods",
"=",
"frozenset",
"(",
"{",
"'GET'",
"}",
")",
",",
"host",
"=",
"None",
",",
"strict_slashes",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"version",
"=",
"None",
",",
"name",
"=",
"No... | Create a blueprint resource route from a decorated function.
:param uri: endpoint at which the route will be accessible.
:param methods: list of acceptable HTTP methods.
:param host:
:param strict_slashes:
:param version:
:param name: user defined route name for url_for
... | [
"Create",
"a",
"blueprint",
"resource",
"route",
"from",
"a",
"decorated",
"function",
"."
] | aafcf8fd019f24abcf519307c4484cc6b4697c04 | https://github.com/olivier-m/rafter/blob/aafcf8fd019f24abcf519307c4484cc6b4697c04/rafter/blueprints.py#L46-L72 | train |
olivier-m/rafter | rafter/blueprints.py | Blueprint.add_resource | def add_resource(self, handler, uri, methods=frozenset({'GET'}),
host=None, strict_slashes=None, version=None, name=None,
**kwargs):
"""
Create a blueprint resource route from a function.
:param uri: endpoint at which the route will be accessible.
... | python | def add_resource(self, handler, uri, methods=frozenset({'GET'}),
host=None, strict_slashes=None, version=None, name=None,
**kwargs):
"""
Create a blueprint resource route from a function.
:param uri: endpoint at which the route will be accessible.
... | [
"def",
"add_resource",
"(",
"self",
",",
"handler",
",",
"uri",
",",
"methods",
"=",
"frozenset",
"(",
"{",
"'GET'",
"}",
")",
",",
"host",
"=",
"None",
",",
"strict_slashes",
"=",
"None",
",",
"version",
"=",
"None",
",",
"name",
"=",
"None",
",",
... | Create a blueprint resource route from a function.
:param uri: endpoint at which the route will be accessible.
:param methods: list of acceptable HTTP methods.
:param host:
:param strict_slashes:
:param version:
:param name: user defined route name for url_for
:r... | [
"Create",
"a",
"blueprint",
"resource",
"route",
"from",
"a",
"function",
"."
] | aafcf8fd019f24abcf519307c4484cc6b4697c04 | https://github.com/olivier-m/rafter/blob/aafcf8fd019f24abcf519307c4484cc6b4697c04/rafter/blueprints.py#L74-L92 | train |
lvieirajr/mongorest | mongorest/database.py | _get_db | def _get_db():
"""
Returns the connection to the database using the settings.
This function should not be called outside of this file.
Use db instead.
"""
from .settings import settings
mongo = settings.MONGODB
if 'URI' in mongo and mongo['URI']:
uri = mongo['URI']
else:
... | python | def _get_db():
"""
Returns the connection to the database using the settings.
This function should not be called outside of this file.
Use db instead.
"""
from .settings import settings
mongo = settings.MONGODB
if 'URI' in mongo and mongo['URI']:
uri = mongo['URI']
else:
... | [
"def",
"_get_db",
"(",
")",
":",
"from",
".",
"settings",
"import",
"settings",
"mongo",
"=",
"settings",
".",
"MONGODB",
"if",
"'URI'",
"in",
"mongo",
"and",
"mongo",
"[",
"'URI'",
"]",
":",
"uri",
"=",
"mongo",
"[",
"'URI'",
"]",
"else",
":",
"uri"... | Returns the connection to the database using the settings.
This function should not be called outside of this file.
Use db instead. | [
"Returns",
"the",
"connection",
"to",
"the",
"database",
"using",
"the",
"settings",
".",
"This",
"function",
"should",
"not",
"be",
"called",
"outside",
"of",
"this",
"file",
".",
"Use",
"db",
"instead",
"."
] | 00f4487ded33254434bc51ff09d48c7a936bd465 | https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/database.py#L91-L124 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_calcR2_getBetas.py | getBetas | def getBetas(idxPrc,
aryPrfTc,
lstAllMdlInd,
aryFuncChnk,
aryBstIndChnk,
betaSw,
queOut):
"""Calculate voxel betas and R^2 for the best model.
Parameters
----------
idxPrc : TODO
(?)
aryPrfTc : np.array, shape (?)... | python | def getBetas(idxPrc,
aryPrfTc,
lstAllMdlInd,
aryFuncChnk,
aryBstIndChnk,
betaSw,
queOut):
"""Calculate voxel betas and R^2 for the best model.
Parameters
----------
idxPrc : TODO
(?)
aryPrfTc : np.array, shape (?)... | [
"def",
"getBetas",
"(",
"idxPrc",
",",
"aryPrfTc",
",",
"lstAllMdlInd",
",",
"aryFuncChnk",
",",
"aryBstIndChnk",
",",
"betaSw",
",",
"queOut",
")",
":",
"# get number of motion directions",
"varNumMtnDrctns",
"=",
"aryPrfTc",
".",
"shape",
"[",
"3",
"]",
"varNu... | Calculate voxel betas and R^2 for the best model.
Parameters
----------
idxPrc : TODO
(?)
aryPrfTc : np.array, shape (?)
Population receptive field time courses.
lstAllMdlInd : list
List of the indices of all models.
aryFuncChnk : TODO
Chunk of something(?)
a... | [
"Calculate",
"voxel",
"betas",
"and",
"R^2",
"for",
"the",
"best",
"model",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_calcR2_getBetas.py#L25-L359 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/frontiers.py | Frontiers.nav_creators | def nav_creators(self, article):
"""
Frontiers method.
Given an Article class instance, this is responsible for returning the
names for creators of the article. For our purposes, it is sufficient to
list only the authors, returning their name, role=aut, and file-as name.
... | python | def nav_creators(self, article):
"""
Frontiers method.
Given an Article class instance, this is responsible for returning the
names for creators of the article. For our purposes, it is sufficient to
list only the authors, returning their name, role=aut, and file-as name.
... | [
"def",
"nav_creators",
"(",
"self",
",",
"article",
")",
":",
"creator_list",
"=",
"[",
"]",
"for",
"contrib_group",
"in",
"article",
".",
"metadata",
".",
"front",
".",
"article_meta",
".",
"contrib_group",
":",
"for",
"contrib",
"in",
"contrib_group",
".",... | Frontiers method.
Given an Article class instance, this is responsible for returning the
names for creators of the article. For our purposes, it is sufficient to
list only the authors, returning their name, role=aut, and file-as name.
This returns a list of Creator(name, role, file_as) | [
"Frontiers",
"method",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/frontiers.py#L27-L65 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/frontiers.py | Frontiers.nav_title | def nav_title(self, article):
"""
Frontiers method.
Given an Article class instance, this will return a string representing
the title of the article. This is done for PloS by serializing the text
in the Article's
"""
article_title = article.metadata.front.article... | python | def nav_title(self, article):
"""
Frontiers method.
Given an Article class instance, this will return a string representing
the title of the article. This is done for PloS by serializing the text
in the Article's
"""
article_title = article.metadata.front.article... | [
"def",
"nav_title",
"(",
"self",
",",
"article",
")",
":",
"article_title",
"=",
"article",
".",
"metadata",
".",
"front",
".",
"article_meta",
".",
"title_group",
".",
"article_title",
".",
"node",
"return",
"str",
"(",
"etree",
".",
"tostring",
"(",
"art... | Frontiers method.
Given an Article class instance, this will return a string representing
the title of the article. This is done for PloS by serializing the text
in the Article's | [
"Frontiers",
"method",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/frontiers.py#L67-L76 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/nlm_transform/citation.py | format_citation | def format_citation(citation, citation_type=None):
"""
This method may be built to support elements from different Tag Suite
versions with the following tag names:
citation, element-citation, mixed-citation, and nlm-citation
The citation-type attribute is optional, and may also be empty; if it ... | python | def format_citation(citation, citation_type=None):
"""
This method may be built to support elements from different Tag Suite
versions with the following tag names:
citation, element-citation, mixed-citation, and nlm-citation
The citation-type attribute is optional, and may also be empty; if it ... | [
"def",
"format_citation",
"(",
"citation",
",",
"citation_type",
"=",
"None",
")",
":",
"cite_types",
"=",
"{",
"'book'",
":",
"self",
".",
"format_book_citation",
",",
"'commun'",
":",
"self",
".",
"format_commun_citation",
",",
"'confproc'",
":",
"self",
"."... | This method may be built to support elements from different Tag Suite
versions with the following tag names:
citation, element-citation, mixed-citation, and nlm-citation
The citation-type attribute is optional, and may also be empty; if it has a
value then it should appear in the following prescrib... | [
"This",
"method",
"may",
"be",
"built",
"to",
"support",
"elements",
"from",
"different",
"Tag",
"Suite",
"versions",
"with",
"the",
"following",
"tag",
"names",
":",
"citation",
"element",
"-",
"citation",
"mixed",
"-",
"citation",
"and",
"nlm",
"-",
"citat... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/nlm_transform/citation.py#L21-L174 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/inputs.py | plos_doi_to_xmlurl | def plos_doi_to_xmlurl(doi_string):
"""
Attempts to resolve a PLoS DOI into a URL path to the XML file.
"""
#Create URL to request DOI resolution from http://dx.doi.org
doi_url = 'http://dx.doi.org/{0}'.format(doi_string)
log.debug('DOI URL: {0}'.format(doi_url))
#Open the page, follow the r... | python | def plos_doi_to_xmlurl(doi_string):
"""
Attempts to resolve a PLoS DOI into a URL path to the XML file.
"""
#Create URL to request DOI resolution from http://dx.doi.org
doi_url = 'http://dx.doi.org/{0}'.format(doi_string)
log.debug('DOI URL: {0}'.format(doi_url))
#Open the page, follow the r... | [
"def",
"plos_doi_to_xmlurl",
"(",
"doi_string",
")",
":",
"#Create URL to request DOI resolution from http://dx.doi.org",
"doi_url",
"=",
"'http://dx.doi.org/{0}'",
".",
"format",
"(",
"doi_string",
")",
"log",
".",
"debug",
"(",
"'DOI URL: {0}'",
".",
"format",
"(",
"d... | Attempts to resolve a PLoS DOI into a URL path to the XML file. | [
"Attempts",
"to",
"resolve",
"a",
"PLoS",
"DOI",
"into",
"a",
"URL",
"path",
"to",
"the",
"XML",
"file",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/inputs.py#L23-L48 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/inputs.py | doi_input | def doi_input(doi_string, download=True):
"""
This method accepts a DOI string and attempts to download the appropriate
xml file. If successful, it returns a path to that file. As with all URL
input types, the success of this method depends on supporting per-publisher
conventions and will fail on un... | python | def doi_input(doi_string, download=True):
"""
This method accepts a DOI string and attempts to download the appropriate
xml file. If successful, it returns a path to that file. As with all URL
input types, the success of this method depends on supporting per-publisher
conventions and will fail on un... | [
"def",
"doi_input",
"(",
"doi_string",
",",
"download",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"'DOI Input - {0}'",
".",
"format",
"(",
"doi_string",
")",
")",
"doi_string",
"=",
"doi_string",
"[",
"4",
":",
"]",
"if",
"'10.1371'",
"in",
"doi_s... | This method accepts a DOI string and attempts to download the appropriate
xml file. If successful, it returns a path to that file. As with all URL
input types, the success of this method depends on supporting per-publisher
conventions and will fail on unsupported publishers | [
"This",
"method",
"accepts",
"a",
"DOI",
"string",
"and",
"attempts",
"to",
"download",
"the",
"appropriate",
"xml",
"file",
".",
"If",
"successful",
"it",
"returns",
"a",
"path",
"to",
"that",
"file",
".",
"As",
"with",
"all",
"URL",
"input",
"types",
"... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/inputs.py#L51-L66 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/inputs.py | url_input | def url_input(url_string, download=True):
"""
This method expects a direct URL link to an xml file. It will apply no
modifications to the received URL string, so ensure good input.
"""
log.debug('URL Input - {0}'.format(url_string))
try:
open_xml = urllib.request.urlopen(url_string)
... | python | def url_input(url_string, download=True):
"""
This method expects a direct URL link to an xml file. It will apply no
modifications to the received URL string, so ensure good input.
"""
log.debug('URL Input - {0}'.format(url_string))
try:
open_xml = urllib.request.urlopen(url_string)
... | [
"def",
"url_input",
"(",
"url_string",
",",
"download",
"=",
"True",
")",
":",
"log",
".",
"debug",
"(",
"'URL Input - {0}'",
".",
"format",
"(",
"url_string",
")",
")",
"try",
":",
"open_xml",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"url_str... | This method expects a direct URL link to an xml file. It will apply no
modifications to the received URL string, so ensure good input. | [
"This",
"method",
"expects",
"a",
"direct",
"URL",
"link",
"to",
"an",
"xml",
"file",
".",
"It",
"will",
"apply",
"no",
"modifications",
"to",
"the",
"received",
"URL",
"string",
"so",
"ensure",
"good",
"input",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/inputs.py#L69-L88 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/inputs.py | frontiersZipInput | def frontiersZipInput(zip_path, output_prefix, download=None):
"""
This method provides support for Frontiers production using base zipfiles
as the input for ePub creation. It expects a valid pathname for one of the
two zipfiles, and that both zipfiles are present in the same directory.
"""
log.... | python | def frontiersZipInput(zip_path, output_prefix, download=None):
"""
This method provides support for Frontiers production using base zipfiles
as the input for ePub creation. It expects a valid pathname for one of the
two zipfiles, and that both zipfiles are present in the same directory.
"""
log.... | [
"def",
"frontiersZipInput",
"(",
"zip_path",
",",
"output_prefix",
",",
"download",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'frontiersZipInput called'",
")",
"#If there is a problem with the input, it should clearly describe the issue",
"pathname",
",",
"pathext",... | This method provides support for Frontiers production using base zipfiles
as the input for ePub creation. It expects a valid pathname for one of the
two zipfiles, and that both zipfiles are present in the same directory. | [
"This",
"method",
"provides",
"support",
"for",
"Frontiers",
"production",
"using",
"base",
"zipfiles",
"as",
"the",
"input",
"for",
"ePub",
"creation",
".",
"It",
"expects",
"a",
"valid",
"pathname",
"for",
"one",
"of",
"the",
"two",
"zipfiles",
"and",
"tha... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/inputs.py#L91-L140 | train |
curious-containers/cc-core | cc_core/commons/red.py | _red_listing_validation | def _red_listing_validation(key, listing):
"""
Raises an RedValidationError, if the given listing does not comply with cwl_job_listing_schema.
If listing is None or an empty list, no exception is thrown.
:param key: The input key to build an error message if needed.
:param listing: The listing to v... | python | def _red_listing_validation(key, listing):
"""
Raises an RedValidationError, if the given listing does not comply with cwl_job_listing_schema.
If listing is None or an empty list, no exception is thrown.
:param key: The input key to build an error message if needed.
:param listing: The listing to v... | [
"def",
"_red_listing_validation",
"(",
"key",
",",
"listing",
")",
":",
"if",
"listing",
":",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"listing",
",",
"cwl_job_listing_schema",
")",
"except",
"ValidationError",
"as",
"e",
":",
"raise",
"RedValidationError... | Raises an RedValidationError, if the given listing does not comply with cwl_job_listing_schema.
If listing is None or an empty list, no exception is thrown.
:param key: The input key to build an error message if needed.
:param listing: The listing to validate
:raise RedValidationError: If the given lis... | [
"Raises",
"an",
"RedValidationError",
"if",
"the",
"given",
"listing",
"does",
"not",
"comply",
"with",
"cwl_job_listing_schema",
".",
"If",
"listing",
"is",
"None",
"or",
"an",
"empty",
"list",
"no",
"exception",
"is",
"thrown",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/red.py#L211-L226 | train |
curious-containers/cc-core | cc_core/commons/red.py | red_get_mount_connectors | def red_get_mount_connectors(red_data, ignore_outputs):
"""
Returns a list of mounting connectors
:param red_data: The red data to be searched
:param ignore_outputs: If outputs should be ignored
:return: A list of connectors with active mount option.
"""
keys = []
batches = red_data.g... | python | def red_get_mount_connectors(red_data, ignore_outputs):
"""
Returns a list of mounting connectors
:param red_data: The red data to be searched
:param ignore_outputs: If outputs should be ignored
:return: A list of connectors with active mount option.
"""
keys = []
batches = red_data.g... | [
"def",
"red_get_mount_connectors",
"(",
"red_data",
",",
"ignore_outputs",
")",
":",
"keys",
"=",
"[",
"]",
"batches",
"=",
"red_data",
".",
"get",
"(",
"'batches'",
")",
"inputs",
"=",
"red_data",
".",
"get",
"(",
"'inputs'",
")",
"if",
"batches",
":",
... | Returns a list of mounting connectors
:param red_data: The red data to be searched
:param ignore_outputs: If outputs should be ignored
:return: A list of connectors with active mount option. | [
"Returns",
"a",
"list",
"of",
"mounting",
"connectors"
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/red.py#L261-L291 | train |
curious-containers/cc-core | cc_core/commons/red.py | cleanup | def cleanup(connector_manager, red_data, tmp_dir):
"""
Invokes the cleanup functions for all inputs.
"""
for key, arg in red_data['inputs'].items():
val = arg
if isinstance(arg, list):
for index, i in enumerate(arg):
if not isinstance(i, dict):
... | python | def cleanup(connector_manager, red_data, tmp_dir):
"""
Invokes the cleanup functions for all inputs.
"""
for key, arg in red_data['inputs'].items():
val = arg
if isinstance(arg, list):
for index, i in enumerate(arg):
if not isinstance(i, dict):
... | [
"def",
"cleanup",
"(",
"connector_manager",
",",
"red_data",
",",
"tmp_dir",
")",
":",
"for",
"key",
",",
"arg",
"in",
"red_data",
"[",
"'inputs'",
"]",
".",
"items",
"(",
")",
":",
"val",
"=",
"arg",
"if",
"isinstance",
"(",
"arg",
",",
"list",
")",... | Invokes the cleanup functions for all inputs. | [
"Invokes",
"the",
"cleanup",
"functions",
"for",
"all",
"inputs",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/red.py#L454-L495 | train |
curious-containers/cc-core | cc_core/commons/red.py | ConnectorManager._execute_connector | def _execute_connector(connector_command, top_level_argument, *file_contents, listing=None):
"""
Executes a connector by executing the given connector_command. The content of args will be the content of the
files handed to the connector cli.
:param connector_command: The connector comma... | python | def _execute_connector(connector_command, top_level_argument, *file_contents, listing=None):
"""
Executes a connector by executing the given connector_command. The content of args will be the content of the
files handed to the connector cli.
:param connector_command: The connector comma... | [
"def",
"_execute_connector",
"(",
"connector_command",
",",
"top_level_argument",
",",
"*",
"file_contents",
",",
"listing",
"=",
"None",
")",
":",
"# create temp_files for every file_content",
"temp_files",
"=",
"[",
"]",
"for",
"file_content",
"in",
"file_contents",
... | Executes a connector by executing the given connector_command. The content of args will be the content of the
files handed to the connector cli.
:param connector_command: The connector command to execute.
:param top_level_argument: The top level command line argument for the connector cli.
... | [
"Executes",
"a",
"connector",
"by",
"executing",
"the",
"given",
"connector_command",
".",
"The",
"content",
"of",
"args",
"will",
"be",
"the",
"content",
"of",
"the",
"files",
"handed",
"to",
"the",
"connector",
"cli",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/red.py#L36-L79 | train |
curious-containers/cc-core | cc_core/commons/red.py | ConnectorManager.directory_listing_content_check | def directory_listing_content_check(directory_path, listing):
"""
Checks if a given listing is present under the given directory path.
:param directory_path: The path to the base directory
:param listing: The listing to check
:return: None if no errors could be found, otherwise ... | python | def directory_listing_content_check(directory_path, listing):
"""
Checks if a given listing is present under the given directory path.
:param directory_path: The path to the base directory
:param listing: The listing to check
:return: None if no errors could be found, otherwise ... | [
"def",
"directory_listing_content_check",
"(",
"directory_path",
",",
"listing",
")",
":",
"if",
"listing",
":",
"for",
"sub",
"in",
"listing",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory_path",
",",
"sub",
"[",
"'basename'",
"]",
")"... | Checks if a given listing is present under the given directory path.
:param directory_path: The path to the base directory
:param listing: The listing to check
:return: None if no errors could be found, otherwise a string describing the error | [
"Checks",
"if",
"a",
"given",
"listing",
"is",
"present",
"under",
"the",
"given",
"directory",
"path",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/red.py#L133-L153 | train |
curious-containers/cc-core | cc_core/commons/gpu_info.py | get_cuda_devices | def get_cuda_devices():
"""
Imports pycuda at runtime and reads GPU information.
:return: A list of available cuda GPUs.
"""
devices = []
try:
import pycuda.autoinit
import pycuda.driver as cuda
for device_id in range(cuda.Device.count()):
vram = cuda.Devic... | python | def get_cuda_devices():
"""
Imports pycuda at runtime and reads GPU information.
:return: A list of available cuda GPUs.
"""
devices = []
try:
import pycuda.autoinit
import pycuda.driver as cuda
for device_id in range(cuda.Device.count()):
vram = cuda.Devic... | [
"def",
"get_cuda_devices",
"(",
")",
":",
"devices",
"=",
"[",
"]",
"try",
":",
"import",
"pycuda",
".",
"autoinit",
"import",
"pycuda",
".",
"driver",
"as",
"cuda",
"for",
"device_id",
"in",
"range",
"(",
"cuda",
".",
"Device",
".",
"count",
"(",
")",... | Imports pycuda at runtime and reads GPU information.
:return: A list of available cuda GPUs. | [
"Imports",
"pycuda",
"at",
"runtime",
"and",
"reads",
"GPU",
"information",
".",
":",
"return",
":",
"A",
"list",
"of",
"available",
"cuda",
"GPUs",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/gpu_info.py#L44-L63 | train |
curious-containers/cc-core | cc_core/commons/gpu_info.py | match_gpus | def match_gpus(available_devices, requirements):
"""
Determines sufficient GPUs for the given requirements and returns a list of GPUDevices.
If there aren't sufficient GPUs a InsufficientGPUException is thrown.
:param available_devices: A list of GPUDevices
:param requirements: A list of GPURequire... | python | def match_gpus(available_devices, requirements):
"""
Determines sufficient GPUs for the given requirements and returns a list of GPUDevices.
If there aren't sufficient GPUs a InsufficientGPUException is thrown.
:param available_devices: A list of GPUDevices
:param requirements: A list of GPURequire... | [
"def",
"match_gpus",
"(",
"available_devices",
",",
"requirements",
")",
":",
"if",
"not",
"requirements",
":",
"return",
"[",
"]",
"if",
"not",
"available_devices",
":",
"raise",
"InsufficientGPUError",
"(",
"\"No GPU devices available, but {} devices required.\"",
"."... | Determines sufficient GPUs for the given requirements and returns a list of GPUDevices.
If there aren't sufficient GPUs a InsufficientGPUException is thrown.
:param available_devices: A list of GPUDevices
:param requirements: A list of GPURequirements
:return: A list of sufficient devices | [
"Determines",
"sufficient",
"GPUs",
"for",
"the",
"given",
"requirements",
"and",
"returns",
"a",
"list",
"of",
"GPUDevices",
".",
"If",
"there",
"aren",
"t",
"sufficient",
"GPUs",
"a",
"InsufficientGPUException",
"is",
"thrown",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/gpu_info.py#L110-L139 | train |
curious-containers/cc-core | cc_core/commons/gpu_info.py | get_gpu_requirements | def get_gpu_requirements(gpus_reqs):
"""
Extracts the GPU from a dictionary requirements as list of GPURequirements.
:param gpus_reqs: A dictionary {'count': <count>} or a list [{min_vram: <min_vram>}, {min_vram: <min_vram>}, ...]
:return: A list of GPURequirements
"""
requirements = []
if... | python | def get_gpu_requirements(gpus_reqs):
"""
Extracts the GPU from a dictionary requirements as list of GPURequirements.
:param gpus_reqs: A dictionary {'count': <count>} or a list [{min_vram: <min_vram>}, {min_vram: <min_vram>}, ...]
:return: A list of GPURequirements
"""
requirements = []
if... | [
"def",
"get_gpu_requirements",
"(",
"gpus_reqs",
")",
":",
"requirements",
"=",
"[",
"]",
"if",
"gpus_reqs",
":",
"if",
"type",
"(",
"gpus_reqs",
")",
"is",
"dict",
":",
"count",
"=",
"gpus_reqs",
".",
"get",
"(",
"'count'",
")",
"if",
"count",
":",
"f... | Extracts the GPU from a dictionary requirements as list of GPURequirements.
:param gpus_reqs: A dictionary {'count': <count>} or a list [{min_vram: <min_vram>}, {min_vram: <min_vram>}, ...]
:return: A list of GPURequirements | [
"Extracts",
"the",
"GPU",
"from",
"a",
"dictionary",
"requirements",
"as",
"list",
"of",
"GPURequirements",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/gpu_info.py#L142-L163 | train |
curious-containers/cc-core | cc_core/commons/gpu_info.py | set_nvidia_environment_variables | def set_nvidia_environment_variables(environment, gpu_ids):
"""
Updates a dictionary containing environment variables to setup Nvidia-GPUs.
:param environment: The environment variables to update
:param gpu_ids: A list of GPU ids
"""
if gpu_ids:
nvidia_visible_devices = ""
for ... | python | def set_nvidia_environment_variables(environment, gpu_ids):
"""
Updates a dictionary containing environment variables to setup Nvidia-GPUs.
:param environment: The environment variables to update
:param gpu_ids: A list of GPU ids
"""
if gpu_ids:
nvidia_visible_devices = ""
for ... | [
"def",
"set_nvidia_environment_variables",
"(",
"environment",
",",
"gpu_ids",
")",
":",
"if",
"gpu_ids",
":",
"nvidia_visible_devices",
"=",
"\"\"",
"for",
"gpu_id",
"in",
"gpu_ids",
":",
"nvidia_visible_devices",
"+=",
"\"{},\"",
".",
"format",
"(",
"gpu_id",
")... | Updates a dictionary containing environment variables to setup Nvidia-GPUs.
:param environment: The environment variables to update
:param gpu_ids: A list of GPU ids | [
"Updates",
"a",
"dictionary",
"containing",
"environment",
"variables",
"to",
"setup",
"Nvidia",
"-",
"GPUs",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/gpu_info.py#L166-L178 | train |
curious-containers/cc-core | cc_core/commons/gpu_info.py | GPURequirement.is_sufficient | def is_sufficient(self, device):
"""
Returns whether the device is sufficient for this requirement.
:param device: A GPUDevice instance.
:type device: GPUDevice
:return: True if the requirement is fulfilled otherwise False
"""
sufficient = True
if (self.... | python | def is_sufficient(self, device):
"""
Returns whether the device is sufficient for this requirement.
:param device: A GPUDevice instance.
:type device: GPUDevice
:return: True if the requirement is fulfilled otherwise False
"""
sufficient = True
if (self.... | [
"def",
"is_sufficient",
"(",
"self",
",",
"device",
")",
":",
"sufficient",
"=",
"True",
"if",
"(",
"self",
".",
"min_vram",
"is",
"not",
"None",
")",
"and",
"(",
"device",
".",
"vram",
"<",
"self",
".",
"min_vram",
")",
":",
"sufficient",
"=",
"Fals... | Returns whether the device is sufficient for this requirement.
:param device: A GPUDevice instance.
:type device: GPUDevice
:return: True if the requirement is fulfilled otherwise False | [
"Returns",
"whether",
"the",
"device",
"is",
"sufficient",
"for",
"this",
"requirement",
"."
] | eaeb03a4366016aff54fcc6953d052ae12ed599b | https://github.com/curious-containers/cc-core/blob/eaeb03a4366016aff54fcc6953d052ae12ed599b/cc_core/commons/gpu_info.py#L28-L41 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | cache_location | def cache_location():
'''Cross-platform placement of cached files'''
plat = platform.platform()
log.debug('Platform read as: {0}'.format(plat))
if plat.startswith('Windows'):
log.debug('Windows platform detected')
return os.path.join(os.environ['APPDATA'], 'OpenAccess_EPUB')
elif pla... | python | def cache_location():
'''Cross-platform placement of cached files'''
plat = platform.platform()
log.debug('Platform read as: {0}'.format(plat))
if plat.startswith('Windows'):
log.debug('Windows platform detected')
return os.path.join(os.environ['APPDATA'], 'OpenAccess_EPUB')
elif pla... | [
"def",
"cache_location",
"(",
")",
":",
"plat",
"=",
"platform",
".",
"platform",
"(",
")",
"log",
".",
"debug",
"(",
"'Platform read as: {0}'",
".",
"format",
"(",
"plat",
")",
")",
"if",
"plat",
".",
"startswith",
"(",
"'Windows'",
")",
":",
"log",
"... | Cross-platform placement of cached files | [
"Cross",
"-",
"platform",
"placement",
"of",
"cached",
"files"
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L86-L109 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | load_config_module | def load_config_module():
"""
If the config.py file exists, import it as a module. If it does not exist,
call sys.exit() with a request to run oaepub configure.
"""
import imp
config_path = config_location()
try:
config = imp.load_source('config', config_path)
except IOError:
... | python | def load_config_module():
"""
If the config.py file exists, import it as a module. If it does not exist,
call sys.exit() with a request to run oaepub configure.
"""
import imp
config_path = config_location()
try:
config = imp.load_source('config', config_path)
except IOError:
... | [
"def",
"load_config_module",
"(",
")",
":",
"import",
"imp",
"config_path",
"=",
"config_location",
"(",
")",
"try",
":",
"config",
"=",
"imp",
".",
"load_source",
"(",
"'config'",
",",
"config_path",
")",
"except",
"IOError",
":",
"log",
".",
"critical",
... | If the config.py file exists, import it as a module. If it does not exist,
call sys.exit() with a request to run oaepub configure. | [
"If",
"the",
"config",
".",
"py",
"file",
"exists",
"import",
"it",
"as",
"a",
"module",
".",
"If",
"it",
"does",
"not",
"exist",
"call",
"sys",
".",
"exit",
"()",
"with",
"a",
"request",
"to",
"run",
"oaepub",
"configure",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L133-L147 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | evaluate_relative_path | def evaluate_relative_path(working=os.getcwd(), relative=''):
"""
This function receives two strings representing system paths. The first is
the working directory and it should be an absolute path. The second is the
relative path and it should not be absolute. This function will render an
OS-appropr... | python | def evaluate_relative_path(working=os.getcwd(), relative=''):
"""
This function receives two strings representing system paths. The first is
the working directory and it should be an absolute path. The second is the
relative path and it should not be absolute. This function will render an
OS-appropr... | [
"def",
"evaluate_relative_path",
"(",
"working",
"=",
"os",
".",
"getcwd",
"(",
")",
",",
"relative",
"=",
"''",
")",
":",
"return",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"working",
",",
"relative",
")",
")"
] | This function receives two strings representing system paths. The first is
the working directory and it should be an absolute path. The second is the
relative path and it should not be absolute. This function will render an
OS-appropriate absolute path, which is the normalized path from working
to relat... | [
"This",
"function",
"receives",
"two",
"strings",
"representing",
"system",
"paths",
".",
"The",
"first",
"is",
"the",
"working",
"directory",
"and",
"it",
"should",
"be",
"an",
"absolute",
"path",
".",
"The",
"second",
"is",
"the",
"relative",
"path",
"and"... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L156-L164 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | get_absolute_path | def get_absolute_path(some_path):
"""
This function will return an appropriate absolute path for the path it is
given. If the input is absolute, it will return unmodified; if the input is
relative, it will be rendered as relative to the current working directory.
"""
if os.path.isabs(some_path):... | python | def get_absolute_path(some_path):
"""
This function will return an appropriate absolute path for the path it is
given. If the input is absolute, it will return unmodified; if the input is
relative, it will be rendered as relative to the current working directory.
"""
if os.path.isabs(some_path):... | [
"def",
"get_absolute_path",
"(",
"some_path",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"some_path",
")",
":",
"return",
"some_path",
"else",
":",
"return",
"evaluate_relative_path",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"some_path",
")"
] | This function will return an appropriate absolute path for the path it is
given. If the input is absolute, it will return unmodified; if the input is
relative, it will be rendered as relative to the current working directory. | [
"This",
"function",
"will",
"return",
"an",
"appropriate",
"absolute",
"path",
"for",
"the",
"path",
"it",
"is",
"given",
".",
"If",
"the",
"input",
"is",
"absolute",
"it",
"will",
"return",
"unmodified",
";",
"if",
"the",
"input",
"is",
"relative",
"it",
... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L167-L176 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | get_output_directory | def get_output_directory(args):
"""
Determination of the directory for output placement involves possibilities
for explicit user instruction (absolute path or relative to execution) and
implicit default configuration (absolute path or relative to input) from
the system global configuration file. Thi... | python | def get_output_directory(args):
"""
Determination of the directory for output placement involves possibilities
for explicit user instruction (absolute path or relative to execution) and
implicit default configuration (absolute path or relative to input) from
the system global configuration file. Thi... | [
"def",
"get_output_directory",
"(",
"args",
")",
":",
"#Import the global config file as a module",
"import",
"imp",
"config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_location",
"(",
")",
",",
"'config.py'",
")",
"try",
":",
"config",
"=",
"imp",
... | Determination of the directory for output placement involves possibilities
for explicit user instruction (absolute path or relative to execution) and
implicit default configuration (absolute path or relative to input) from
the system global configuration file. This function is responsible for
reliably r... | [
"Determination",
"of",
"the",
"directory",
"for",
"output",
"placement",
"involves",
"possibilities",
"for",
"explicit",
"user",
"instruction",
"(",
"absolute",
"path",
"or",
"relative",
"to",
"execution",
")",
"and",
"implicit",
"default",
"configuration",
"(",
"... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L179-L243 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | file_root_name | def file_root_name(name):
"""
Returns the root name of a file from a full file path.
It will not raise an error if the result is empty, but an warning will be
issued.
"""
base = os.path.basename(name)
root = os.path.splitext(base)[0]
if not root:
warning = 'file_root_name return... | python | def file_root_name(name):
"""
Returns the root name of a file from a full file path.
It will not raise an error if the result is empty, but an warning will be
issued.
"""
base = os.path.basename(name)
root = os.path.splitext(base)[0]
if not root:
warning = 'file_root_name return... | [
"def",
"file_root_name",
"(",
"name",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"name",
")",
"root",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"base",
")",
"[",
"0",
"]",
"if",
"not",
"root",
":",
"warning",
"=",
"'file_... | Returns the root name of a file from a full file path.
It will not raise an error if the result is empty, but an warning will be
issued. | [
"Returns",
"the",
"root",
"name",
"of",
"a",
"file",
"from",
"a",
"full",
"file",
"path",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L246-L258 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | files_with_ext | def files_with_ext(extension, directory='.', recursive=False):
"""
Generator function that will iterate over all files in the specified
directory and return a path to the files which possess a matching extension.
You should include the period in your extension, and matching is not case
sensitive: '... | python | def files_with_ext(extension, directory='.', recursive=False):
"""
Generator function that will iterate over all files in the specified
directory and return a path to the files which possess a matching extension.
You should include the period in your extension, and matching is not case
sensitive: '... | [
"def",
"files_with_ext",
"(",
"extension",
",",
"directory",
"=",
"'.'",
",",
"recursive",
"=",
"False",
")",
":",
"if",
"recursive",
":",
"log",
".",
"info",
"(",
"'Recursively searching {0} for files with extension \"{1}\"'",
".",
"format",
"(",
"directory",
","... | Generator function that will iterate over all files in the specified
directory and return a path to the files which possess a matching extension.
You should include the period in your extension, and matching is not case
sensitive: '.xml' will also match '.XML' and vice versa.
An empty string passed to... | [
"Generator",
"function",
"that",
"will",
"iterate",
"over",
"all",
"files",
"in",
"the",
"specified",
"directory",
"and",
"return",
"a",
"path",
"to",
"the",
"files",
"which",
"possess",
"a",
"matching",
"extension",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L261-L288 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | epubcheck | def epubcheck(epubname, config=None):
"""
This method takes the name of an epub file as an argument. This name is
the input for the java execution of a locally installed epubcheck-.jar. The
location of this .jar file is configured in config.py.
"""
if config is None:
config = load_config... | python | def epubcheck(epubname, config=None):
"""
This method takes the name of an epub file as an argument. This name is
the input for the java execution of a locally installed epubcheck-.jar. The
location of this .jar file is configured in config.py.
"""
if config is None:
config = load_config... | [
"def",
"epubcheck",
"(",
"epubname",
",",
"config",
"=",
"None",
")",
":",
"if",
"config",
"is",
"None",
":",
"config",
"=",
"load_config_module",
"(",
")",
"r",
",",
"e",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"epubname",
")",
"if",
"not",
... | This method takes the name of an epub file as an argument. This name is
the input for the java execution of a locally installed epubcheck-.jar. The
location of this .jar file is configured in config.py. | [
"This",
"method",
"takes",
"the",
"name",
"of",
"an",
"epub",
"file",
"as",
"an",
"argument",
".",
"This",
"name",
"is",
"the",
"input",
"for",
"the",
"java",
"execution",
"of",
"a",
"locally",
"installed",
"epubcheck",
"-",
".",
"jar",
".",
"The",
"lo... | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L291-L307 | train |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/utils/__init__.py | dir_exists | def dir_exists(directory):
"""
If a directory already exists that will be overwritten by some action, this
will ask the user whether or not to continue with the deletion.
If the user responds affirmatively, then the directory will be removed. If
the user responds negatively, then the process will a... | python | def dir_exists(directory):
"""
If a directory already exists that will be overwritten by some action, this
will ask the user whether or not to continue with the deletion.
If the user responds affirmatively, then the directory will be removed. If
the user responds negatively, then the process will a... | [
"def",
"dir_exists",
"(",
"directory",
")",
":",
"log",
".",
"info",
"(",
"'Directory exists! Asking the user'",
")",
"reply",
"=",
"input",
"(",
"'''The directory {0} already exists.\nIt will be overwritten if the operation continues.\nReplace? [Y/n]'''",
".",
"format",
"(",
... | If a directory already exists that will be overwritten by some action, this
will ask the user whether or not to continue with the deletion.
If the user responds affirmatively, then the directory will be removed. If
the user responds negatively, then the process will abort. | [
"If",
"a",
"directory",
"already",
"exists",
"that",
"will",
"be",
"overwritten",
"by",
"some",
"action",
"this",
"will",
"ask",
"the",
"user",
"whether",
"or",
"not",
"to",
"continue",
"with",
"the",
"deletion",
"."
] | 6b77ba30b7394fd003920e7a7957bca963a90656 | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/utils/__init__.py#L310-L327 | train |
bachya/pyflunearyou | pyflunearyou/helpers/geo.py | get_nearest_by_coordinates | def get_nearest_by_coordinates(
data: list, latitude_key: str, longitude_key: str,
target_latitude: float, target_longitude: float) -> Any:
"""Get the closest dict entry based on latitude/longitude."""
return min(
data,
key=lambda p: haversine(
target_latitude,
... | python | def get_nearest_by_coordinates(
data: list, latitude_key: str, longitude_key: str,
target_latitude: float, target_longitude: float) -> Any:
"""Get the closest dict entry based on latitude/longitude."""
return min(
data,
key=lambda p: haversine(
target_latitude,
... | [
"def",
"get_nearest_by_coordinates",
"(",
"data",
":",
"list",
",",
"latitude_key",
":",
"str",
",",
"longitude_key",
":",
"str",
",",
"target_latitude",
":",
"float",
",",
"target_longitude",
":",
"float",
")",
"->",
"Any",
":",
"return",
"min",
"(",
"data"... | Get the closest dict entry based on latitude/longitude. | [
"Get",
"the",
"closest",
"dict",
"entry",
"based",
"on",
"latitude",
"/",
"longitude",
"."
] | 16a2f839c8df851e925e010a6b5c5708386febac | https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/helpers/geo.py#L7-L18 | train |
bachya/pyflunearyou | pyflunearyou/helpers/geo.py | haversine | def haversine(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
"""Determine the distance between two latitude/longitude pairs."""
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
calc_a = sin(dlat / 2)**2 + co... | python | def haversine(lat1: float, lon1: float, lat2: float, lon2: float) -> float:
"""Determine the distance between two latitude/longitude pairs."""
lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2])
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
calc_a = sin(dlat / 2)**2 + co... | [
"def",
"haversine",
"(",
"lat1",
":",
"float",
",",
"lon1",
":",
"float",
",",
"lat2",
":",
"float",
",",
"lon2",
":",
"float",
")",
"->",
"float",
":",
"lon1",
",",
"lat1",
",",
"lon2",
",",
"lat2",
"=",
"map",
"(",
"radians",
",",
"[",
"lon1",
... | Determine the distance between two latitude/longitude pairs. | [
"Determine",
"the",
"distance",
"between",
"two",
"latitude",
"/",
"longitude",
"pairs",
"."
] | 16a2f839c8df851e925e010a6b5c5708386febac | https://github.com/bachya/pyflunearyou/blob/16a2f839c8df851e925e010a6b5c5708386febac/pyflunearyou/helpers/geo.py#L21-L31 | train |
ChrisTimperley/Kaskara | python/kaskara/insertions.py | InsertionPointDB.in_file | def in_file(self, fn: str) -> Iterator[InsertionPoint]:
"""
Returns an iterator over all of the insertion points in a given file.
"""
logger.debug("finding insertion points in file: %s", fn)
yield from self.__file_insertions.get(fn, []) | python | def in_file(self, fn: str) -> Iterator[InsertionPoint]:
"""
Returns an iterator over all of the insertion points in a given file.
"""
logger.debug("finding insertion points in file: %s", fn)
yield from self.__file_insertions.get(fn, []) | [
"def",
"in_file",
"(",
"self",
",",
"fn",
":",
"str",
")",
"->",
"Iterator",
"[",
"InsertionPoint",
"]",
":",
"logger",
".",
"debug",
"(",
"\"finding insertion points in file: %s\"",
",",
"fn",
")",
"yield",
"from",
"self",
".",
"__file_insertions",
".",
"ge... | Returns an iterator over all of the insertion points in a given file. | [
"Returns",
"an",
"iterator",
"over",
"all",
"of",
"the",
"insertion",
"points",
"in",
"a",
"given",
"file",
"."
] | 3d182d95b2938508e5990eddd30321be15e2f2ef | https://github.com/ChrisTimperley/Kaskara/blob/3d182d95b2938508e5990eddd30321be15e2f2ef/python/kaskara/insertions.py#L91-L96 | train |
ChrisTimperley/Kaskara | python/kaskara/insertions.py | InsertionPointDB.at_line | def at_line(self, line: FileLine) -> Iterator[InsertionPoint]:
"""
Returns an iterator over all of the insertion points located at a
given line.
"""
logger.debug("finding insertion points at line: %s", str(line))
filename = line.filename # type: str
line_num = li... | python | def at_line(self, line: FileLine) -> Iterator[InsertionPoint]:
"""
Returns an iterator over all of the insertion points located at a
given line.
"""
logger.debug("finding insertion points at line: %s", str(line))
filename = line.filename # type: str
line_num = li... | [
"def",
"at_line",
"(",
"self",
",",
"line",
":",
"FileLine",
")",
"->",
"Iterator",
"[",
"InsertionPoint",
"]",
":",
"logger",
".",
"debug",
"(",
"\"finding insertion points at line: %s\"",
",",
"str",
"(",
"line",
")",
")",
"filename",
"=",
"line",
".",
"... | Returns an iterator over all of the insertion points located at a
given line. | [
"Returns",
"an",
"iterator",
"over",
"all",
"of",
"the",
"insertion",
"points",
"located",
"at",
"a",
"given",
"line",
"."
] | 3d182d95b2938508e5990eddd30321be15e2f2ef | https://github.com/ChrisTimperley/Kaskara/blob/3d182d95b2938508e5990eddd30321be15e2f2ef/python/kaskara/insertions.py#L98-L110 | train |
linkhub-sdk/popbill.py | popbill/closedownService.py | ClosedownService.getUnitCost | def getUnitCost(self, CorpNum):
""" 휴폐업조회 단가 확인.
args
CorpNum : 팝빌회원 사업자번호
return
발행단가 by float
raise
PopbillException
"""
result = self._httpget('/CloseDown/UnitCost', CorpNum)
return float(result.unit... | python | def getUnitCost(self, CorpNum):
""" 휴폐업조회 단가 확인.
args
CorpNum : 팝빌회원 사업자번호
return
발행단가 by float
raise
PopbillException
"""
result = self._httpget('/CloseDown/UnitCost', CorpNum)
return float(result.unit... | [
"def",
"getUnitCost",
"(",
"self",
",",
"CorpNum",
")",
":",
"result",
"=",
"self",
".",
"_httpget",
"(",
"'/CloseDown/UnitCost'",
",",
"CorpNum",
")",
"return",
"float",
"(",
"result",
".",
"unitCost",
")"
] | 휴폐업조회 단가 확인.
args
CorpNum : 팝빌회원 사업자번호
return
발행단가 by float
raise
PopbillException | [
"휴폐업조회",
"단가",
"확인",
".",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"return",
"발행단가",
"by",
"float",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/closedownService.py#L39-L51 | train |
linkhub-sdk/popbill.py | popbill/closedownService.py | ClosedownService.checkCorpNum | def checkCorpNum(self, MemberCorpNum, CheckCorpNum):
""" 휴폐업조회 - 단건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNum : 조회할 사업자번호
MgtKey : 문서관리번호
return
휴폐업정보 object
raise
PopbillException
"""
... | python | def checkCorpNum(self, MemberCorpNum, CheckCorpNum):
""" 휴폐업조회 - 단건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNum : 조회할 사업자번호
MgtKey : 문서관리번호
return
휴폐업정보 object
raise
PopbillException
"""
... | [
"def",
"checkCorpNum",
"(",
"self",
",",
"MemberCorpNum",
",",
"CheckCorpNum",
")",
":",
"if",
"MemberCorpNum",
"==",
"None",
"or",
"MemberCorpNum",
"==",
"\"\"",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"팝빌회원 사업자번호가 입력되지 않았습니다.\")",
"",
"i... | 휴폐업조회 - 단건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNum : 조회할 사업자번호
MgtKey : 문서관리번호
return
휴폐업정보 object
raise
PopbillException | [
"휴폐업조회",
"-",
"단건",
"args",
"MemberCorpNum",
":",
"팝빌회원",
"사업자번호",
"CorpNum",
":",
"조회할",
"사업자번호",
"MgtKey",
":",
"문서관리번호",
"return",
"휴폐업정보",
"object",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/closedownService.py#L53-L71 | train |
linkhub-sdk/popbill.py | popbill/closedownService.py | ClosedownService.checkCorpNums | def checkCorpNums(self, MemberCorpNum, CorpNumList):
""" 휴폐업조회 대량 확인, 최대 1000건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNumList : 조회할 사업자번호 배열
return
휴폐업정보 Object as List
raise
PopbillException
"""
if ... | python | def checkCorpNums(self, MemberCorpNum, CorpNumList):
""" 휴폐업조회 대량 확인, 최대 1000건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNumList : 조회할 사업자번호 배열
return
휴폐업정보 Object as List
raise
PopbillException
"""
if ... | [
"def",
"checkCorpNums",
"(",
"self",
",",
"MemberCorpNum",
",",
"CorpNumList",
")",
":",
"if",
"CorpNumList",
"==",
"None",
"or",
"len",
"(",
"CorpNumList",
")",
"<",
"1",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"조죄할 사업자번호 목록이 입력되지 않았습니다... | 휴폐업조회 대량 확인, 최대 1000건
args
MemberCorpNum : 팝빌회원 사업자번호
CorpNumList : 조회할 사업자번호 배열
return
휴폐업정보 Object as List
raise
PopbillException | [
"휴폐업조회",
"대량",
"확인",
"최대",
"1000건",
"args",
"MemberCorpNum",
":",
"팝빌회원",
"사업자번호",
"CorpNumList",
":",
"조회할",
"사업자번호",
"배열",
"return",
"휴폐업정보",
"Object",
"as",
"List",
"raise",
"PopbillException"
] | 68a0dd7f7a937603318e93be321fde73c50b96cc | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/closedownService.py#L73-L88 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | loadPng | def loadPng(varNumVol, tplPngSize, strPathPng):
"""Load PNG files.
Parameters
----------
varNumVol : float
Number of volumes, i.e. number of time points in all runs.
tplPngSize : tuple
Shape of the stimulus image (i.e. png).
strPathPng: str
Path to the folder cointaining... | python | def loadPng(varNumVol, tplPngSize, strPathPng):
"""Load PNG files.
Parameters
----------
varNumVol : float
Number of volumes, i.e. number of time points in all runs.
tplPngSize : tuple
Shape of the stimulus image (i.e. png).
strPathPng: str
Path to the folder cointaining... | [
"def",
"loadPng",
"(",
"varNumVol",
",",
"tplPngSize",
",",
"strPathPng",
")",
":",
"print",
"(",
"'------Load PNGs'",
")",
"# Create list of png files to load:",
"lstPngPaths",
"=",
"[",
"None",
"]",
"*",
"varNumVol",
"for",
"idx01",
"in",
"range",
"(",
"0",
... | Load PNG files.
Parameters
----------
varNumVol : float
Number of volumes, i.e. number of time points in all runs.
tplPngSize : tuple
Shape of the stimulus image (i.e. png).
strPathPng: str
Path to the folder cointaining the png files.
Returns
-------
aryPngData ... | [
"Load",
"PNG",
"files",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L29-L66 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | loadPrsOrd | def loadPrsOrd(vecRunLngth, strPathPresOrd, vecVslStim):
"""Load presentation order of motion directions.
Parameters
----------
vecRunLngth : list
Number of volumes in every run
strPathPresOrd : str
Path to the npy vector containing order of presented motion directions.
vecVslSt... | python | def loadPrsOrd(vecRunLngth, strPathPresOrd, vecVslStim):
"""Load presentation order of motion directions.
Parameters
----------
vecRunLngth : list
Number of volumes in every run
strPathPresOrd : str
Path to the npy vector containing order of presented motion directions.
vecVslSt... | [
"def",
"loadPrsOrd",
"(",
"vecRunLngth",
",",
"strPathPresOrd",
",",
"vecVslStim",
")",
":",
"print",
"(",
"'------Load presentation order of motion directions'",
")",
"aryPresOrd",
"=",
"np",
".",
"empty",
"(",
"(",
"0",
",",
"2",
")",
")",
"for",
"idx01",
"i... | Load presentation order of motion directions.
Parameters
----------
vecRunLngth : list
Number of volumes in every run
strPathPresOrd : str
Path to the npy vector containing order of presented motion directions.
vecVslStim: list
Key of (stimulus) condition presented in every ... | [
"Load",
"presentation",
"order",
"of",
"motion",
"directions",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L69-L105 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | crtPwBoxCarFn | def crtPwBoxCarFn(varNumVol, aryPngData, aryPresOrd, vecMtDrctn):
"""Create pixel-wise boxcar functions.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
input2 : float, positive
Description of input 2.
Returns
-------
... | python | def crtPwBoxCarFn(varNumVol, aryPngData, aryPresOrd, vecMtDrctn):
"""Create pixel-wise boxcar functions.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
input2 : float, positive
Description of input 2.
Returns
-------
... | [
"def",
"crtPwBoxCarFn",
"(",
"varNumVol",
",",
"aryPngData",
",",
"aryPresOrd",
",",
"vecMtDrctn",
")",
":",
"print",
"(",
"'------Create pixel-wise boxcar functions'",
")",
"aryBoxCar",
"=",
"np",
".",
"empty",
"(",
"aryPngData",
".",
"shape",
"[",
"0",
":",
... | Create pixel-wise boxcar functions.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
input2 : float, positive
Description of input 2.
Returns
-------
data : 2d numpy array, shape [n_samples, n_measurements]
Closed... | [
"Create",
"pixel",
"-",
"wise",
"boxcar",
"functions",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L108-L135 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | crtGauss2D | def crtGauss2D(varSizeX, varSizeY, varPosX, varPosY, varSd):
"""Create 2D Gaussian kernel.
Parameters
----------
varSizeX : int, positive
Width of the visual field.
varSizeY : int, positive
Height of the visual field..
varPosX : int, positive
X position of centre of 2D G... | python | def crtGauss2D(varSizeX, varSizeY, varPosX, varPosY, varSd):
"""Create 2D Gaussian kernel.
Parameters
----------
varSizeX : int, positive
Width of the visual field.
varSizeY : int, positive
Height of the visual field..
varPosX : int, positive
X position of centre of 2D G... | [
"def",
"crtGauss2D",
"(",
"varSizeX",
",",
"varSizeY",
",",
"varPosX",
",",
"varPosY",
",",
"varSd",
")",
":",
"varSizeX",
"=",
"int",
"(",
"varSizeX",
")",
"varSizeY",
"=",
"int",
"(",
"varSizeY",
")",
"# aryX and aryY are in reversed order, this seems to be nece... | Create 2D Gaussian kernel.
Parameters
----------
varSizeX : int, positive
Width of the visual field.
varSizeY : int, positive
Height of the visual field..
varPosX : int, positive
X position of centre of 2D Gauss.
varPosY : int, positive
Y position of centre of 2D... | [
"Create",
"2D",
"Gaussian",
"kernel",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L138-L175 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | cnvlGauss2D | def cnvlGauss2D(idxPrc, aryBoxCar, aryMdlParamsChnk, tplPngSize, varNumVol,
queOut):
"""Spatially convolve boxcar functions with 2D Gaussian.
Parameters
----------
idxPrc : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
aryBoxCar : float, positive
... | python | def cnvlGauss2D(idxPrc, aryBoxCar, aryMdlParamsChnk, tplPngSize, varNumVol,
queOut):
"""Spatially convolve boxcar functions with 2D Gaussian.
Parameters
----------
idxPrc : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
aryBoxCar : float, positive
... | [
"def",
"cnvlGauss2D",
"(",
"idxPrc",
",",
"aryBoxCar",
",",
"aryMdlParamsChnk",
",",
"tplPngSize",
",",
"varNumVol",
",",
"queOut",
")",
":",
"# Number of combinations of model parameters in the current chunk:",
"varChnkSze",
"=",
"np",
".",
"size",
"(",
"aryMdlParamsCh... | Spatially convolve boxcar functions with 2D Gaussian.
Parameters
----------
idxPrc : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
aryBoxCar : float, positive
Description of input 2.
aryMdlParamsChnk : 2d numpy array, shape [n_samples, n_measurements]
... | [
"Spatially",
"convolve",
"boxcar",
"functions",
"with",
"2D",
"Gaussian",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L178-L250 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | crtPrfNrlTc | def crtPrfNrlTc(aryBoxCar, varNumMtDrctn, varNumVol, tplPngSize, varNumX,
varExtXmin, varExtXmax, varNumY, varExtYmin, varExtYmax,
varNumPrfSizes, varPrfStdMin, varPrfStdMax, varPar):
"""Create neural model time courses from pixel-wise boxcar functions.
Parameters
---------... | python | def crtPrfNrlTc(aryBoxCar, varNumMtDrctn, varNumVol, tplPngSize, varNumX,
varExtXmin, varExtXmax, varNumY, varExtYmin, varExtYmax,
varNumPrfSizes, varPrfStdMin, varPrfStdMax, varPar):
"""Create neural model time courses from pixel-wise boxcar functions.
Parameters
---------... | [
"def",
"crtPrfNrlTc",
"(",
"aryBoxCar",
",",
"varNumMtDrctn",
",",
"varNumVol",
",",
"tplPngSize",
",",
"varNumX",
",",
"varExtXmin",
",",
"varExtXmax",
",",
"varNumY",
",",
"varExtYmin",
",",
"varExtYmax",
",",
"varNumPrfSizes",
",",
"varPrfStdMin",
",",
"varPr... | Create neural model time courses from pixel-wise boxcar functions.
Parameters
----------
aryBoxCar : 4d numpy array, shape [n_x_pix, n_y_pix, n_mtn_dir, n_vol]
Description of input 1.
varNumMtDrctn : float, positive
Description of input 2.
varNumVol : float, positive
Descrip... | [
"Create",
"neural",
"model",
"time",
"courses",
"from",
"pixel",
"-",
"wise",
"boxcar",
"functions",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L253-L445 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | cnvlPwBoxCarFn | def cnvlPwBoxCarFn(aryNrlTc, varNumVol, varTr, tplPngSize, varNumMtDrctn,
switchHrfSet, lgcOldSchoolHrf, varPar,):
"""Create 2D Gaussian kernel.
Parameters
----------
aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol]
Description of input 1.
varNu... | python | def cnvlPwBoxCarFn(aryNrlTc, varNumVol, varTr, tplPngSize, varNumMtDrctn,
switchHrfSet, lgcOldSchoolHrf, varPar,):
"""Create 2D Gaussian kernel.
Parameters
----------
aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol]
Description of input 1.
varNu... | [
"def",
"cnvlPwBoxCarFn",
"(",
"aryNrlTc",
",",
"varNumVol",
",",
"varTr",
",",
"tplPngSize",
",",
"varNumMtDrctn",
",",
"switchHrfSet",
",",
"lgcOldSchoolHrf",
",",
"varPar",
",",
")",
":",
"print",
"(",
"'------Convolve every pixel box car function with hrf function(s)... | Create 2D Gaussian kernel.
Parameters
----------
aryNrlTc : 5d numpy array, shape [n_x_pos, n_y_pos, n_sd, n_mtn_dir, n_vol]
Description of input 1.
varNumVol : float, positive
Description of input 2.
varTr : float, positive
Description of input 1.
tplPngSize : tuple
... | [
"Create",
"2D",
"Gaussian",
"kernel",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L448-L562 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/old/pRF_mdlCrt.py | rsmplInHighRes | def rsmplInHighRes(aryBoxCarConv,
tplPngSize,
tplVslSpcHighSze,
varNumMtDrctn,
varNumVol):
"""Resample pixel-time courses in high-res visual space.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements... | python | def rsmplInHighRes(aryBoxCarConv,
tplPngSize,
tplVslSpcHighSze,
varNumMtDrctn,
varNumVol):
"""Resample pixel-time courses in high-res visual space.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements... | [
"def",
"rsmplInHighRes",
"(",
"aryBoxCarConv",
",",
"tplPngSize",
",",
"tplVslSpcHighSze",
",",
"varNumMtDrctn",
",",
"varNumVol",
")",
":",
"# Array for super-sampled pixel-time courses:",
"aryBoxCarConvHigh",
"=",
"np",
".",
"zeros",
"(",
"(",
"tplVslSpcHighSze",
"[",... | Resample pixel-time courses in high-res visual space.
Parameters
----------
input1 : 2d numpy array, shape [n_samples, n_measurements]
Description of input 1.
input2 : float, positive
Description of input 2.
Returns
-------
data : 2d numpy array, shape [n_samples, n_measuremen... | [
"Resample",
"pixel",
"-",
"time",
"courses",
"in",
"high",
"-",
"res",
"visual",
"space",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/old/pRF_mdlCrt.py#L565-L633 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/pyprf_sim_ep.py | get_arg_parse | def get_arg_parse():
"""Parses the Command Line Arguments using argparse."""
# Create parser object:
objParser = argparse.ArgumentParser()
# Add argument to namespace -strCsvPrf results file path:
objParser.add_argument('-strCsvPrf', required=True,
metavar='/path/to/my_pr... | python | def get_arg_parse():
"""Parses the Command Line Arguments using argparse."""
# Create parser object:
objParser = argparse.ArgumentParser()
# Add argument to namespace -strCsvPrf results file path:
objParser.add_argument('-strCsvPrf', required=True,
metavar='/path/to/my_pr... | [
"def",
"get_arg_parse",
"(",
")",
":",
"# Create parser object:",
"objParser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"# Add argument to namespace -strCsvPrf results file path:",
"objParser",
".",
"add_argument",
"(",
"'-strCsvPrf'",
",",
"required",
"=",
"True... | Parses the Command Line Arguments using argparse. | [
"Parses",
"the",
"Command",
"Line",
"Arguments",
"using",
"argparse",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim_ep.py#L14-L54 | train |
MSchnei/pyprf_feature | pyprf_feature/analysis/pyprf_sim_ep.py | main | def main():
"""pyprf_sim entry point."""
# Get list of input arguments (without first one, which is the path to the
# function that is called): --NOTE: This is another way of accessing
# input arguments, but since we use 'argparse' it is redundant.
# lstArgs = sys.argv[1:]
strWelcome = 'pyprf_s... | python | def main():
"""pyprf_sim entry point."""
# Get list of input arguments (without first one, which is the path to the
# function that is called): --NOTE: This is another way of accessing
# input arguments, but since we use 'argparse' it is redundant.
# lstArgs = sys.argv[1:]
strWelcome = 'pyprf_s... | [
"def",
"main",
"(",
")",
":",
"# Get list of input arguments (without first one, which is the path to the",
"# function that is called): --NOTE: This is another way of accessing",
"# input arguments, but since we use 'argparse' it is redundant.",
"# lstArgs = sys.argv[1:]",
"strWelcome",
"=",
... | pyprf_sim entry point. | [
"pyprf_sim",
"entry",
"point",
"."
] | 49004ede7ae1ddee07a30afe9ce3e2776750805c | https://github.com/MSchnei/pyprf_feature/blob/49004ede7ae1ddee07a30afe9ce3e2776750805c/pyprf_feature/analysis/pyprf_sim_ep.py#L57-L83 | train |
lvieirajr/mongorest | mongorest/decorators.py | login_required | def login_required(wrapped):
"""
Requires that the user is logged in and authorized to execute requests
Except if the method is in authorized_methods of the auth_collection
Then he can execute the requests even not being authorized
"""
@wraps(wrapped)
def wrapper(*args, **kwargs):
re... | python | def login_required(wrapped):
"""
Requires that the user is logged in and authorized to execute requests
Except if the method is in authorized_methods of the auth_collection
Then he can execute the requests even not being authorized
"""
@wraps(wrapped)
def wrapper(*args, **kwargs):
re... | [
"def",
"login_required",
"(",
"wrapped",
")",
":",
"@",
"wraps",
"(",
"wrapped",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"request",
"=",
"args",
"[",
"1",
"]",
"auth_collection",
"=",
"settings",
".",
"AUTH_COLLECTIO... | Requires that the user is logged in and authorized to execute requests
Except if the method is in authorized_methods of the auth_collection
Then he can execute the requests even not being authorized | [
"Requires",
"that",
"the",
"user",
"is",
"logged",
"in",
"and",
"authorized",
"to",
"execute",
"requests",
"Except",
"if",
"the",
"method",
"is",
"in",
"authorized_methods",
"of",
"the",
"auth_collection",
"Then",
"he",
"can",
"execute",
"the",
"requests",
"ev... | 00f4487ded33254434bc51ff09d48c7a936bd465 | https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/decorators.py#L17-L44 | train |
lvieirajr/mongorest | mongorest/decorators.py | serializable | def serializable(wrapped):
"""
If a keyword argument 'serialize' with a True value is passed to the
Wrapped function, the return of the wrapped function will be serialized.
Nothing happens if the argument is not passed or the value is not True
"""
@wraps(wrapped)
def wrapper(*args, **kwargs... | python | def serializable(wrapped):
"""
If a keyword argument 'serialize' with a True value is passed to the
Wrapped function, the return of the wrapped function will be serialized.
Nothing happens if the argument is not passed or the value is not True
"""
@wraps(wrapped)
def wrapper(*args, **kwargs... | [
"def",
"serializable",
"(",
"wrapped",
")",
":",
"@",
"wraps",
"(",
"wrapped",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"should_serialize",
"=",
"kwargs",
".",
"pop",
"(",
"'serialize'",
",",
"False",
")",
"result",
... | If a keyword argument 'serialize' with a True value is passed to the
Wrapped function, the return of the wrapped function will be serialized.
Nothing happens if the argument is not passed or the value is not True | [
"If",
"a",
"keyword",
"argument",
"serialize",
"with",
"a",
"True",
"value",
"is",
"passed",
"to",
"the",
"Wrapped",
"function",
"the",
"return",
"of",
"the",
"wrapped",
"function",
"will",
"be",
"serialized",
".",
"Nothing",
"happens",
"if",
"the",
"argumen... | 00f4487ded33254434bc51ff09d48c7a936bd465 | https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/decorators.py#L47-L67 | train |
lvieirajr/mongorest | mongorest/utils.py | deserialize | def deserialize(to_deserialize, *args, **kwargs):
"""
Deserializes a string into a PyMongo BSON
"""
if isinstance(to_deserialize, string_types):
if re.match('^[0-9a-f]{24}$', to_deserialize):
return ObjectId(to_deserialize)
try:
return bson_loads(to_deserialize, *... | python | def deserialize(to_deserialize, *args, **kwargs):
"""
Deserializes a string into a PyMongo BSON
"""
if isinstance(to_deserialize, string_types):
if re.match('^[0-9a-f]{24}$', to_deserialize):
return ObjectId(to_deserialize)
try:
return bson_loads(to_deserialize, *... | [
"def",
"deserialize",
"(",
"to_deserialize",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"to_deserialize",
",",
"string_types",
")",
":",
"if",
"re",
".",
"match",
"(",
"'^[0-9a-f]{24}$'",
",",
"to_deserialize",
")",
":",
... | Deserializes a string into a PyMongo BSON | [
"Deserializes",
"a",
"string",
"into",
"a",
"PyMongo",
"BSON"
] | 00f4487ded33254434bc51ff09d48c7a936bd465 | https://github.com/lvieirajr/mongorest/blob/00f4487ded33254434bc51ff09d48c7a936bd465/mongorest/utils.py#L16-L28 | train |
musically-ut/seqfile | seqfile/seqfile.py | _doAtomicFileCreation | def _doAtomicFileCreation(filePath):
"""Tries to atomically create the requested file."""
try:
_os.close(_os.open(filePath, _os.O_CREAT | _os.O_EXCL))
return True
except OSError as e:
if e.errno == _errno.EEXIST:
return False
else:
raise e | python | def _doAtomicFileCreation(filePath):
"""Tries to atomically create the requested file."""
try:
_os.close(_os.open(filePath, _os.O_CREAT | _os.O_EXCL))
return True
except OSError as e:
if e.errno == _errno.EEXIST:
return False
else:
raise e | [
"def",
"_doAtomicFileCreation",
"(",
"filePath",
")",
":",
"try",
":",
"_os",
".",
"close",
"(",
"_os",
".",
"open",
"(",
"filePath",
",",
"_os",
".",
"O_CREAT",
"|",
"_os",
".",
"O_EXCL",
")",
")",
"return",
"True",
"except",
"OSError",
"as",
"e",
"... | Tries to atomically create the requested file. | [
"Tries",
"to",
"atomically",
"create",
"the",
"requested",
"file",
"."
] | 796e366fe8871b6dc72cb6bbc570e4a61a8f947c | https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L11-L20 | train |
musically-ut/seqfile | seqfile/seqfile.py | findNextFile | def findNextFile(folder='.',
prefix=None,
suffix=None,
fnameGen=None,
base=0,
maxattempts=10):
"""Finds the next available file-name in a sequence.
This function will create a file of zero size and will return the path to
... | python | def findNextFile(folder='.',
prefix=None,
suffix=None,
fnameGen=None,
base=0,
maxattempts=10):
"""Finds the next available file-name in a sequence.
This function will create a file of zero size and will return the path to
... | [
"def",
"findNextFile",
"(",
"folder",
"=",
"'.'",
",",
"prefix",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"fnameGen",
"=",
"None",
",",
"base",
"=",
"0",
",",
"maxattempts",
"=",
"10",
")",
":",
"expFolder",
"=",
"_os",
".",
"path",
".",
"expa... | Finds the next available file-name in a sequence.
This function will create a file of zero size and will return the path to
it to the caller. No files which exist will be altered in this operation
and concurrent executions of this function will return separate files. In
case of conflict, the function w... | [
"Finds",
"the",
"next",
"available",
"file",
"-",
"name",
"in",
"a",
"sequence",
"."
] | 796e366fe8871b6dc72cb6bbc570e4a61a8f947c | https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L97-L145 | train |
musically-ut/seqfile | seqfile/seqfile.py | _run | def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None):
"""Executes the script, gets prefix/suffix from the command prompt and
produces output on STDOUT. For help with command line options, invoke
script with '--help'.
"""
description = """Finds the next available file-name in a sequence.... | python | def _run(passedArgs=None, stderr=None, stdout=None, exitFn=None):
"""Executes the script, gets prefix/suffix from the command prompt and
produces output on STDOUT. For help with command line options, invoke
script with '--help'.
"""
description = """Finds the next available file-name in a sequence.... | [
"def",
"_run",
"(",
"passedArgs",
"=",
"None",
",",
"stderr",
"=",
"None",
",",
"stdout",
"=",
"None",
",",
"exitFn",
"=",
"None",
")",
":",
"description",
"=",
"\"\"\"Finds the next available file-name in a sequence.\n\n This program will create a file of zero size an... | Executes the script, gets prefix/suffix from the command prompt and
produces output on STDOUT. For help with command line options, invoke
script with '--help'. | [
"Executes",
"the",
"script",
"gets",
"prefix",
"/",
"suffix",
"from",
"the",
"command",
"prompt",
"and",
"produces",
"output",
"on",
"STDOUT",
".",
"For",
"help",
"with",
"command",
"line",
"options",
"invoke",
"script",
"with",
"--",
"help",
"."
] | 796e366fe8871b6dc72cb6bbc570e4a61a8f947c | https://github.com/musically-ut/seqfile/blob/796e366fe8871b6dc72cb6bbc570e4a61a8f947c/seqfile/seqfile.py#L148-L215 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _errstr | def _errstr(value):
"""Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If
it's truncated, the returned value will have '...' on the end.
"""
value = str(value) # We won't make the caller convert value to a string each time.
if len(value) > MAX_ERROR_STR_LEN:
return value[:... | python | def _errstr(value):
"""Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If
it's truncated, the returned value will have '...' on the end.
"""
value = str(value) # We won't make the caller convert value to a string each time.
if len(value) > MAX_ERROR_STR_LEN:
return value[:... | [
"def",
"_errstr",
"(",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"# We won't make the caller convert value to a string each time.",
"if",
"len",
"(",
"value",
")",
">",
"MAX_ERROR_STR_LEN",
":",
"return",
"value",
"[",
":",
"MAX_ERROR_STR_LEN",
"]... | Returns the value str, truncated to MAX_ERROR_STR_LEN characters. If
it's truncated, the returned value will have '...' on the end. | [
"Returns",
"the",
"value",
"str",
"truncated",
"to",
"MAX_ERROR_STR_LEN",
"characters",
".",
"If",
"it",
"s",
"truncated",
"the",
"returned",
"value",
"will",
"have",
"...",
"on",
"the",
"end",
"."
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L75-L84 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _getStrippedValue | def _getStrippedValue(value, strip):
"""Like the strip() string method, except the strip argument describes
different behavior:
If strip is None, whitespace is stripped.
If strip is a string, the characters in the string are stripped.
If strip is False, nothing is stripped."""
if strip is Non... | python | def _getStrippedValue(value, strip):
"""Like the strip() string method, except the strip argument describes
different behavior:
If strip is None, whitespace is stripped.
If strip is a string, the characters in the string are stripped.
If strip is False, nothing is stripped."""
if strip is Non... | [
"def",
"_getStrippedValue",
"(",
"value",
",",
"strip",
")",
":",
"if",
"strip",
"is",
"None",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"# Call strip() with no arguments to strip whitespace.",
"elif",
"isinstance",
"(",
"strip",
",",
"str",
")",
":"... | Like the strip() string method, except the strip argument describes
different behavior:
If strip is None, whitespace is stripped.
If strip is a string, the characters in the string are stripped.
If strip is False, nothing is stripped. | [
"Like",
"the",
"strip",
"()",
"string",
"method",
"except",
"the",
"strip",
"argument",
"describes",
"different",
"behavior",
":"
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L87-L102 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _raiseValidationException | def _raiseValidationException(standardExcMsg, customExcMsg=None):
"""Raise ValidationException with standardExcMsg, unless customExcMsg is specified."""
if customExcMsg is None:
raise ValidationException(str(standardExcMsg))
else:
raise ValidationException(str(customExcMsg)) | python | def _raiseValidationException(standardExcMsg, customExcMsg=None):
"""Raise ValidationException with standardExcMsg, unless customExcMsg is specified."""
if customExcMsg is None:
raise ValidationException(str(standardExcMsg))
else:
raise ValidationException(str(customExcMsg)) | [
"def",
"_raiseValidationException",
"(",
"standardExcMsg",
",",
"customExcMsg",
"=",
"None",
")",
":",
"if",
"customExcMsg",
"is",
"None",
":",
"raise",
"ValidationException",
"(",
"str",
"(",
"standardExcMsg",
")",
")",
"else",
":",
"raise",
"ValidationException"... | Raise ValidationException with standardExcMsg, unless customExcMsg is specified. | [
"Raise",
"ValidationException",
"with",
"standardExcMsg",
"unless",
"customExcMsg",
"is",
"specified",
"."
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L105-L110 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _prevalidationCheck | def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None):
"""Returns a tuple of two values: the first is a bool that tells the caller
if they should immediately return True, the second is a new, possibly stripped
value to replace the value passed for value parameter.
... | python | def _prevalidationCheck(value, blank, strip, allowlistRegexes, blocklistRegexes, excMsg=None):
"""Returns a tuple of two values: the first is a bool that tells the caller
if they should immediately return True, the second is a new, possibly stripped
value to replace the value passed for value parameter.
... | [
"def",
"_prevalidationCheck",
"(",
"value",
",",
"blank",
",",
"strip",
",",
"allowlistRegexes",
",",
"blocklistRegexes",
",",
"excMsg",
"=",
"None",
")",
":",
"# TODO - add a allowlistFirst and blocklistFirst to determine which is checked first. (Right now it's allowlist)",
"v... | Returns a tuple of two values: the first is a bool that tells the caller
if they should immediately return True, the second is a new, possibly stripped
value to replace the value passed for value parameter.
We'd want the caller immediately return value in some cases where further
validation isn't neede... | [
"Returns",
"a",
"tuple",
"of",
"two",
"values",
":",
"the",
"first",
"is",
"a",
"bool",
"that",
"tells",
"the",
"caller",
"if",
"they",
"should",
"immediately",
"return",
"True",
"the",
"second",
"is",
"a",
"new",
"possibly",
"stripped",
"value",
"to",
"... | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L113-L164 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _validateGenericParameters | def _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes):
"""Returns None if the blank, strip, and blocklistRegexes parameters are valid
of PySimpleValidate's validation functions have. Raises a PySimpleValidateException
if any of the arguments are invalid."""
# Check blank para... | python | def _validateGenericParameters(blank, strip, allowlistRegexes, blocklistRegexes):
"""Returns None if the blank, strip, and blocklistRegexes parameters are valid
of PySimpleValidate's validation functions have. Raises a PySimpleValidateException
if any of the arguments are invalid."""
# Check blank para... | [
"def",
"_validateGenericParameters",
"(",
"blank",
",",
"strip",
",",
"allowlistRegexes",
",",
"blocklistRegexes",
")",
":",
"# Check blank parameter.",
"if",
"not",
"isinstance",
"(",
"blank",
",",
"bool",
")",
":",
"raise",
"PySimpleValidateException",
"(",
"'blan... | Returns None if the blank, strip, and blocklistRegexes parameters are valid
of PySimpleValidate's validation functions have. Raises a PySimpleValidateException
if any of the arguments are invalid. | [
"Returns",
"None",
"if",
"the",
"blank",
"strip",
"and",
"blocklistRegexes",
"parameters",
"are",
"valid",
"of",
"PySimpleValidate",
"s",
"validation",
"functions",
"have",
".",
"Raises",
"a",
"PySimpleValidateException",
"if",
"any",
"of",
"the",
"arguments",
"ar... | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L167-L209 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _validateParamsFor_validateNum | def _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None):
"""Raises an exception if the arguments are invalid. This is called by
the validateNum(), validateInt(), and validateFloat() functions to
check its arguments. This code was refactored out to a separate function
so t... | python | def _validateParamsFor_validateNum(min=None, max=None, lessThan=None, greaterThan=None):
"""Raises an exception if the arguments are invalid. This is called by
the validateNum(), validateInt(), and validateFloat() functions to
check its arguments. This code was refactored out to a separate function
so t... | [
"def",
"_validateParamsFor_validateNum",
"(",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",
"lessThan",
"=",
"None",
",",
"greaterThan",
"=",
"None",
")",
":",
"if",
"(",
"min",
"is",
"not",
"None",
")",
"and",
"(",
"greaterThan",
"is",
"not",
"Non... | Raises an exception if the arguments are invalid. This is called by
the validateNum(), validateInt(), and validateFloat() functions to
check its arguments. This code was refactored out to a separate function
so that the PyInputPlus module (or other modules) could check their
parameters' arguments for in... | [
"Raises",
"an",
"exception",
"if",
"the",
"arguments",
"are",
"invalid",
".",
"This",
"is",
"called",
"by",
"the",
"validateNum",
"()",
"validateInt",
"()",
"and",
"validateFloat",
"()",
"functions",
"to",
"check",
"its",
"arguments",
".",
"This",
"code",
"w... | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L212-L235 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | validateStr | def validateStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None):
"""Raises ValidationException if value is not a string. This function
is identical to the built-in input() function, but also offers the
PySimpleValidate features of not allowing blank values by defau... | python | def validateStr(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, excMsg=None):
"""Raises ValidationException if value is not a string. This function
is identical to the built-in input() function, but also offers the
PySimpleValidate features of not allowing blank values by defau... | [
"def",
"validateStr",
"(",
"value",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"excMsg",
"=",
"None",
")",
":",
"# Validate parameters.",
"_validateGenericParameters",
... | Raises ValidationException if value is not a string. This function
is identical to the built-in input() function, but also offers the
PySimpleValidate features of not allowing blank values by default,
automatically stripping whitespace, and having allowlist/blocklist
regular expressions.
Returns va... | [
"Raises",
"ValidationException",
"if",
"value",
"is",
"not",
"a",
"string",
".",
"This",
"function",
"is",
"identical",
"to",
"the",
"built",
"-",
"in",
"input",
"()",
"function",
"but",
"also",
"offers",
"the",
"PySimpleValidate",
"features",
"of",
"not",
"... | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L238-L283 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | validateNum | def validateNum(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, _numType='num',
min=None, max=None, lessThan=None, greaterThan=None, excMsg=None):
"""Raises ValidationException if value is not a float or int.
Returns value, so it can be used inline in an expression... | python | def validateNum(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None, _numType='num',
min=None, max=None, lessThan=None, greaterThan=None, excMsg=None):
"""Raises ValidationException if value is not a float or int.
Returns value, so it can be used inline in an expression... | [
"def",
"validateNum",
"(",
"value",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"_numType",
"=",
"'num'",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",... | Raises ValidationException if value is not a float or int.
Returns value, so it can be used inline in an expression:
print(2 + validateNum(your_number))
Note that since int() and float() ignore leading or trailing whitespace
when converting a string to a number, so does this validateNum().
*... | [
"Raises",
"ValidationException",
"if",
"value",
"is",
"not",
"a",
"float",
"or",
"int",
"."
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L286-L393 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | validateInt | def validateInt(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
min=None, max=None, lessThan=None, greaterThan=None, excMsg=None):
"""Raises ValidationException if value is not a int.
Returns value, so it can be used inline in an expression:
print(2 + vali... | python | def validateInt(value, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
min=None, max=None, lessThan=None, greaterThan=None, excMsg=None):
"""Raises ValidationException if value is not a int.
Returns value, so it can be used inline in an expression:
print(2 + vali... | [
"def",
"validateInt",
"(",
"value",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
",",
"lessThan",
"=",
"None",
",",
... | Raises ValidationException if value is not a int.
Returns value, so it can be used inline in an expression:
print(2 + validateInt(your_number))
Note that since int() and ignore leading or trailing whitespace
when converting a string to a number, so does this validateNum().
* value (str): The... | [
"Raises",
"ValidationException",
"if",
"value",
"is",
"not",
"a",
"int",
"."
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L396-L432 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | _validateParamsFor_validateChoice | def _validateParamsFor_validateChoice(choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
numbered=False, lettered=False, caseSensitive=False, excMsg=None):
"""Raises PySimpleValidateException if the arguments are invalid. This is called by
the validateChoice() fun... | python | def _validateParamsFor_validateChoice(choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
numbered=False, lettered=False, caseSensitive=False, excMsg=None):
"""Raises PySimpleValidateException if the arguments are invalid. This is called by
the validateChoice() fun... | [
"def",
"_validateParamsFor_validateChoice",
"(",
"choices",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"numbered",
"=",
"False",
",",
"lettered",
"=",
"False",
",",
... | Raises PySimpleValidateException if the arguments are invalid. This is called by
the validateChoice() function to check its arguments. This code was
refactored out to a separate function so that the PyInputPlus module (or
other modules) could check their parameters' arguments for inputChoice(). | [
"Raises",
"PySimpleValidateException",
"if",
"the",
"arguments",
"are",
"invalid",
".",
"This",
"is",
"called",
"by",
"the",
"validateChoice",
"()",
"function",
"to",
"check",
"its",
"arguments",
".",
"This",
"code",
"was",
"refactored",
"out",
"to",
"a",
"sep... | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L488-L523 | train |
asweigart/pysimplevalidate | src/pysimplevalidate/__init__.py | validateChoice | def validateChoice(value, choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
numbered=False, lettered=False, caseSensitive=False, excMsg=None):
"""Raises ValidationException if value is not one of the values in
choices. Returns the selected choice.
Returns th... | python | def validateChoice(value, choices, blank=False, strip=None, allowlistRegexes=None, blocklistRegexes=None,
numbered=False, lettered=False, caseSensitive=False, excMsg=None):
"""Raises ValidationException if value is not one of the values in
choices. Returns the selected choice.
Returns th... | [
"def",
"validateChoice",
"(",
"value",
",",
"choices",
",",
"blank",
"=",
"False",
",",
"strip",
"=",
"None",
",",
"allowlistRegexes",
"=",
"None",
",",
"blocklistRegexes",
"=",
"None",
",",
"numbered",
"=",
"False",
",",
"lettered",
"=",
"False",
",",
"... | Raises ValidationException if value is not one of the values in
choices. Returns the selected choice.
Returns the value in choices that was selected, so it can be used inline
in an expression:
print('You chose ' + validateChoice(your_choice, ['cat', 'dog']))
Note that value itself is not retu... | [
"Raises",
"ValidationException",
"if",
"value",
"is",
"not",
"one",
"of",
"the",
"values",
"in",
"choices",
".",
"Returns",
"the",
"selected",
"choice",
"."
] | 3ca27228abb7355d14bbf8abc225c63366379e44 | https://github.com/asweigart/pysimplevalidate/blob/3ca27228abb7355d14bbf8abc225c63366379e44/src/pysimplevalidate/__init__.py#L526-L608 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.