repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
collectiveacuity/labPack | labpack/records/time.py | labDT.fromEpoch | def fromEpoch(cls, epoch_time):
''' a method for constructing a labDT object from epoch timestamp
:param epoch_time: number with epoch timestamp info
:return: labDT object
'''
# validate input
title = 'Epoch time input for labDT.fromEpoch'
if not isinstan... | python | def fromEpoch(cls, epoch_time):
''' a method for constructing a labDT object from epoch timestamp
:param epoch_time: number with epoch timestamp info
:return: labDT object
'''
# validate input
title = 'Epoch time input for labDT.fromEpoch'
if not isinstan... | [
"def",
"fromEpoch",
"(",
"cls",
",",
"epoch_time",
")",
":",
"# validate input\r",
"title",
"=",
"'Epoch time input for labDT.fromEpoch'",
"if",
"not",
"isinstance",
"(",
"epoch_time",
",",
"float",
")",
"and",
"not",
"isinstance",
"(",
"epoch_time",
",",
"int",
... | a method for constructing a labDT object from epoch timestamp
:param epoch_time: number with epoch timestamp info
:return: labDT object | [
"a",
"method",
"for",
"constructing",
"a",
"labDT",
"object",
"from",
"epoch",
"timestamp",
":",
"param",
"epoch_time",
":",
"number",
"with",
"epoch",
"timestamp",
"info",
":",
"return",
":",
"labDT",
"object"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/time.py#L181-L206 |
collectiveacuity/labPack | labpack/records/time.py | labDT.fromISO | def fromISO(cls, iso_string):
''' a method for constructing a labDT object from a timezone aware ISO string
:param iso_string: string with date and time info in ISO format
:return: labDT object
'''
# validate input
title = 'ISO time input for labDT.fromISO... | python | def fromISO(cls, iso_string):
''' a method for constructing a labDT object from a timezone aware ISO string
:param iso_string: string with date and time info in ISO format
:return: labDT object
'''
# validate input
title = 'ISO time input for labDT.fromISO... | [
"def",
"fromISO",
"(",
"cls",
",",
"iso_string",
")",
":",
"# validate input\r",
"title",
"=",
"'ISO time input for labDT.fromISO'",
"isopattern",
"=",
"re",
".",
"compile",
"(",
"'\\d{4}-?\\d{2}-?\\d{2}[\\s|T].*'",
")",
"if",
"not",
"isopattern",
".",
"search",
"("... | a method for constructing a labDT object from a timezone aware ISO string
:param iso_string: string with date and time info in ISO format
:return: labDT object | [
"a",
"method",
"for",
"constructing",
"a",
"labDT",
"object",
"from",
"a",
"timezone",
"aware",
"ISO",
"string",
":",
"param",
"iso_string",
":",
"string",
"with",
"date",
"and",
"time",
"info",
"in",
"ISO",
"format",
":",
"return",
":",
"labDT",
"object"
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/time.py#L209-L238 |
collectiveacuity/labPack | labpack/records/time.py | labDT.fromPython | def fromPython(cls, python_datetime):
''' a method for constructing a labDT from a python datetime with timezone info
:param python_datetime: datetime object with timezone info
:return: labDT object
'''
# validate inputs
title = 'Python datetime input for ... | python | def fromPython(cls, python_datetime):
''' a method for constructing a labDT from a python datetime with timezone info
:param python_datetime: datetime object with timezone info
:return: labDT object
'''
# validate inputs
title = 'Python datetime input for ... | [
"def",
"fromPython",
"(",
"cls",
",",
"python_datetime",
")",
":",
"# validate inputs\r",
"title",
"=",
"'Python datetime input for labDT.fromPython'",
"if",
"not",
"isinstance",
"(",
"python_datetime",
",",
"datetime",
")",
":",
"raise",
"TypeError",
"(",
"'\\n%s mus... | a method for constructing a labDT from a python datetime with timezone info
:param python_datetime: datetime object with timezone info
:return: labDT object | [
"a",
"method",
"for",
"constructing",
"a",
"labDT",
"from",
"a",
"python",
"datetime",
"with",
"timezone",
"info",
":",
"param",
"python_datetime",
":",
"datetime",
"object",
"with",
"timezone",
"info",
":",
"return",
":",
"labDT",
"object"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/time.py#L241-L268 |
collectiveacuity/labPack | labpack/records/time.py | labDT.fromJavascript | def fromJavascript(cls, javascript_datetime):
''' a method to construct labDT from a javascript datetime string
:param javascript_datetime: string with datetime info in javascript formatting
:return: labDT object
'''
# validate inputs
title = 'Javascript d... | python | def fromJavascript(cls, javascript_datetime):
''' a method to construct labDT from a javascript datetime string
:param javascript_datetime: string with datetime info in javascript formatting
:return: labDT object
'''
# validate inputs
title = 'Javascript d... | [
"def",
"fromJavascript",
"(",
"cls",
",",
"javascript_datetime",
")",
":",
"# validate inputs\r",
"title",
"=",
"'Javascript datetime string input for labDT.fromJavascript'",
"jsDTpattern",
"=",
"re",
".",
"compile",
"(",
"'\\s*\\(.*\\)$'",
")",
"jsGMTpattern",
"=",
"re",... | a method to construct labDT from a javascript datetime string
:param javascript_datetime: string with datetime info in javascript formatting
:return: labDT object | [
"a",
"method",
"to",
"construct",
"labDT",
"from",
"a",
"javascript",
"datetime",
"string",
":",
"param",
"javascript_datetime",
":",
"string",
"with",
"datetime",
"info",
"in",
"javascript",
"formatting",
":",
"return",
":",
"labDT",
"object"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/time.py#L271-L304 |
collectiveacuity/labPack | labpack/records/time.py | labDT.fromPattern | def fromPattern(cls, datetime_string, datetime_pattern, time_zone, require_hour=True):
'''
a method for constructing labDT from a strptime pattern in a string
https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
iso_pattern: '%Y-%m-%dT%H:%M:%S.... | python | def fromPattern(cls, datetime_string, datetime_pattern, time_zone, require_hour=True):
'''
a method for constructing labDT from a strptime pattern in a string
https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
iso_pattern: '%Y-%m-%dT%H:%M:%S.... | [
"def",
"fromPattern",
"(",
"cls",
",",
"datetime_string",
",",
"datetime_pattern",
",",
"time_zone",
",",
"require_hour",
"=",
"True",
")",
":",
"# validate inputs\r",
"title",
"=",
"'input for labDT.fromPattern'",
"dT_req",
"=",
"[",
"[",
"'%Y'",
",",
"'%y'",
"... | a method for constructing labDT from a strptime pattern in a string
https://docs.python.org/2/library/datetime.html#strftime-and-strptime-behavior
iso_pattern: '%Y-%m-%dT%H:%M:%S.%f%z'
human_friendly_pattern: '%A, %B %d, %Y %I:%M:%S.%f%p'
:param datetime_string: string wi... | [
"a",
"method",
"for",
"constructing",
"labDT",
"from",
"a",
"strptime",
"pattern",
"in",
"a",
"string",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"2",
"/",
"library",
"/",
"datetime",
".",
"html#strftime",
"-",
"and",
"-",
"strptime",
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/records/time.py#L307-L350 |
stephanepechard/projy | projy/templates/DjangoProjectTemplate.py | DjangoProjectTemplate.directories | def directories(self):
""" Return the names of directories to be created. """
directories_description = [
self.project_name,
self.project_name + '/conf',
self.project_name + '/static',
]
return directories_description | python | def directories(self):
""" Return the names of directories to be created. """
directories_description = [
self.project_name,
self.project_name + '/conf',
self.project_name + '/static',
]
return directories_description | [
"def",
"directories",
"(",
"self",
")",
":",
"directories_description",
"=",
"[",
"self",
".",
"project_name",
",",
"self",
".",
"project_name",
"+",
"'/conf'",
",",
"self",
".",
"project_name",
"+",
"'/static'",
",",
"]",
"return",
"directories_description"
] | Return the names of directories to be created. | [
"Return",
"the",
"names",
"of",
"directories",
"to",
"be",
"created",
"."
] | train | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/DjangoProjectTemplate.py#L23-L30 |
stephanepechard/projy | projy/templates/DjangoProjectTemplate.py | DjangoProjectTemplate.substitutes | def substitutes(self):
""" Return the substitutions for the templating replacements. """
author_collector = AuthorCollector()
mail_collector = AuthorMailCollector()
substitute_dict = {
'project': self.project_name,
'project_lower': self.project_name.lower(),
... | python | def substitutes(self):
""" Return the substitutions for the templating replacements. """
author_collector = AuthorCollector()
mail_collector = AuthorMailCollector()
substitute_dict = {
'project': self.project_name,
'project_lower': self.project_name.lower(),
... | [
"def",
"substitutes",
"(",
"self",
")",
":",
"author_collector",
"=",
"AuthorCollector",
"(",
")",
"mail_collector",
"=",
"AuthorMailCollector",
"(",
")",
"substitute_dict",
"=",
"{",
"'project'",
":",
"self",
".",
"project_name",
",",
"'project_lower'",
":",
"s... | Return the substitutions for the templating replacements. | [
"Return",
"the",
"substitutions",
"for",
"the",
"templating",
"replacements",
"."
] | train | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/templates/DjangoProjectTemplate.py#L81-L92 |
collectiveacuity/labPack | labpack/parsing/flask.py | extract_request_details | def extract_request_details(request_object, session_object=None):
'''
a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
... | python | def extract_request_details(request_object, session_object=None):
'''
a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
... | [
"def",
"extract_request_details",
"(",
"request_object",
",",
"session_object",
"=",
"None",
")",
":",
"request_details",
"=",
"{",
"'error'",
":",
"''",
",",
"'status'",
":",
"'ok'",
",",
"'code'",
":",
"200",
",",
"'method'",
":",
"request_object",
".",
"m... | a method for extracting request details from request and session objects
NOTE: method is also a placeholder funnel for future validation
processes, request logging, request context building and
counter-measures for the nasty web
:param request_object: request object... | [
"a",
"method",
"for",
"extracting",
"request",
"details",
"from",
"request",
"and",
"session",
"objects",
"NOTE",
":",
"method",
"is",
"also",
"a",
"placeholder",
"funnel",
"for",
"future",
"validation",
"processes",
"request",
"logging",
"request",
"context",
"... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/flask.py#L23-L85 |
collectiveacuity/labPack | labpack/parsing/flask.py | extract_session_details | def extract_session_details(request_headers, session_header, secret_key):
'''
a method to extract and validate jwt session token from request headers
:param request_headers: dictionary with header fields from request
:param session_header: string with name of session token header key
:p... | python | def extract_session_details(request_headers, session_header, secret_key):
'''
a method to extract and validate jwt session token from request headers
:param request_headers: dictionary with header fields from request
:param session_header: string with name of session token header key
:p... | [
"def",
"extract_session_details",
"(",
"request_headers",
",",
"session_header",
",",
"secret_key",
")",
":",
"session_details",
"=",
"{",
"'error'",
":",
"''",
",",
"'code'",
":",
"200",
",",
"'session'",
":",
"{",
"}",
"}",
"if",
"not",
"session_header",
"... | a method to extract and validate jwt session token from request headers
:param request_headers: dictionary with header fields from request
:param session_header: string with name of session token header key
:param secret_key: string with secret key to json web token encryption
:return: dictionary ... | [
"a",
"method",
"to",
"extract",
"and",
"validate",
"jwt",
"session",
"token",
"from",
"request",
"headers",
":",
"param",
"request_headers",
":",
"dictionary",
"with",
"header",
"fields",
"from",
"request",
":",
"param",
"session_header",
":",
"string",
"with",
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/flask.py#L87-L122 |
collectiveacuity/labPack | labpack/parsing/flask.py | validate_request_content | def validate_request_content(request_content, request_model, request_component='body'):
'''
a method to validate the content fields of a flask request
:param request_content: dictionary with content fields to validate
:param request_model: object with jsonmodel class properties
... | python | def validate_request_content(request_content, request_model, request_component='body'):
'''
a method to validate the content fields of a flask request
:param request_content: dictionary with content fields to validate
:param request_model: object with jsonmodel class properties
... | [
"def",
"validate_request_content",
"(",
"request_content",
",",
"request_model",
",",
"request_component",
"=",
"'body'",
")",
":",
"# import dependencies\r",
"from",
"jsonmodel",
".",
"validators",
"import",
"jsonModel",
"from",
"jsonmodel",
".",
"exceptions",
"import"... | a method to validate the content fields of a flask request
:param request_content: dictionary with content fields to validate
:param request_model: object with jsonmodel class properties
:param request_component: string with name of component of request evaluated
:return: dictionary with ... | [
"a",
"method",
"to",
"validate",
"the",
"content",
"fields",
"of",
"a",
"flask",
"request",
":",
"param",
"request_content",
":",
"dictionary",
"with",
"content",
"fields",
"to",
"validate",
":",
"param",
"request_model",
":",
"object",
"with",
"jsonmodel",
"c... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/parsing/flask.py#L124-L186 |
alexpearce/jobmonitor | jobmonitor/FlaskWithJobResolvers.py | FlaskWithJobResolvers.remove_job_resolver | def remove_job_resolver(self, job_resolver):
"""Remove job_resolver from the list of job resolvers.
Keyword arguments:
job_resolver -- Function reference of the job resolver to be removed.
"""
for i, r in enumerate(self.job_resolvers()):
if job_resolver == r:
... | python | def remove_job_resolver(self, job_resolver):
"""Remove job_resolver from the list of job resolvers.
Keyword arguments:
job_resolver -- Function reference of the job resolver to be removed.
"""
for i, r in enumerate(self.job_resolvers()):
if job_resolver == r:
... | [
"def",
"remove_job_resolver",
"(",
"self",
",",
"job_resolver",
")",
":",
"for",
"i",
",",
"r",
"in",
"enumerate",
"(",
"self",
".",
"job_resolvers",
"(",
")",
")",
":",
"if",
"job_resolver",
"==",
"r",
":",
"del",
"self",
".",
"_job_resolvers",
"[",
"... | Remove job_resolver from the list of job resolvers.
Keyword arguments:
job_resolver -- Function reference of the job resolver to be removed. | [
"Remove",
"job_resolver",
"from",
"the",
"list",
"of",
"job",
"resolvers",
"."
] | train | https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/FlaskWithJobResolvers.py#L60-L68 |
alexpearce/jobmonitor | jobmonitor/FlaskWithJobResolvers.py | FlaskWithJobResolvers.resolve_job | def resolve_job(self, name):
"""Attempt to resolve the task name in to a job name.
If no job resolver can resolve the task, i.e. they all return None,
return None.
Keyword arguments:
name -- Name of the task to be resolved.
"""
for r in self.job_resolvers():
... | python | def resolve_job(self, name):
"""Attempt to resolve the task name in to a job name.
If no job resolver can resolve the task, i.e. they all return None,
return None.
Keyword arguments:
name -- Name of the task to be resolved.
"""
for r in self.job_resolvers():
... | [
"def",
"resolve_job",
"(",
"self",
",",
"name",
")",
":",
"for",
"r",
"in",
"self",
".",
"job_resolvers",
"(",
")",
":",
"resolved_name",
"=",
"r",
"(",
"name",
")",
"if",
"resolved_name",
"is",
"not",
"None",
":",
"return",
"resolved_name",
"return",
... | Attempt to resolve the task name in to a job name.
If no job resolver can resolve the task, i.e. they all return None,
return None.
Keyword arguments:
name -- Name of the task to be resolved. | [
"Attempt",
"to",
"resolve",
"the",
"task",
"name",
"in",
"to",
"a",
"job",
"name",
"."
] | train | https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/FlaskWithJobResolvers.py#L70-L83 |
tripzero/python-photons | photons/lightprotocol.py | LightProtocol.writeHeader | def writeHeader(self, msg):
"""write header:
[8bit][16bit]
[protocol_version][msg_length]
"""
header = bytearray([self.protocol_version]) #protocol version 1.0
header.extend(struct.pack('<H', len(msg)))
msg = header + msg
return msg | python | def writeHeader(self, msg):
"""write header:
[8bit][16bit]
[protocol_version][msg_length]
"""
header = bytearray([self.protocol_version]) #protocol version 1.0
header.extend(struct.pack('<H', len(msg)))
msg = header + msg
return msg | [
"def",
"writeHeader",
"(",
"self",
",",
"msg",
")",
":",
"header",
"=",
"bytearray",
"(",
"[",
"self",
".",
"protocol_version",
"]",
")",
"#protocol version 1.0",
"header",
".",
"extend",
"(",
"struct",
".",
"pack",
"(",
"'<H'",
",",
"len",
"(",
"msg",
... | write header:
[8bit][16bit]
[protocol_version][msg_length] | [
"write",
"header",
":",
"[",
"8bit",
"]",
"[",
"16bit",
"]",
"[",
"protocol_version",
"]",
"[",
"msg_length",
"]"
] | train | https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L147-L158 |
tripzero/python-photons | photons/lightprotocol.py | LightProtocol.setColor | def setColor(self, id, color):
"""
Command 0x01
sets the color of a specific light
Data:
[Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]...
"""
header = bytearray()
header.append(LightProtocolCommand.SetColor)
if not isinstance(id, list):
id = [id]
if not isinstance(color, list)... | python | def setColor(self, id, color):
"""
Command 0x01
sets the color of a specific light
Data:
[Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]...
"""
header = bytearray()
header.append(LightProtocolCommand.SetColor)
if not isinstance(id, list):
id = [id]
if not isinstance(color, list)... | [
"def",
"setColor",
"(",
"self",
",",
"id",
",",
"color",
")",
":",
"header",
"=",
"bytearray",
"(",
")",
"header",
".",
"append",
"(",
"LightProtocolCommand",
".",
"SetColor",
")",
"if",
"not",
"isinstance",
"(",
"id",
",",
"list",
")",
":",
"id",
"=... | Command 0x01
sets the color of a specific light
Data:
[Command][Number_Lights_to_set][id_1][r][g][b][id_n][r][g][b]... | [
"Command",
"0x01",
"sets",
"the",
"color",
"of",
"a",
"specific",
"light"
] | train | https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L160-L190 |
tripzero/python-photons | photons/lightprotocol.py | LightProtocol.setSeries | def setSeries(self, startId, length, color):
"""
Command 0x07
sets all lights in the series starting from "startId" to "endId" to "color"
Data:
[0x07][startId][length][r][g][b]
"""
buff = bytearray()
buff.append(LightProtocolCommand.SetSeries)
buff.extend(struct.pack('<H', startId))
buff.extend(st... | python | def setSeries(self, startId, length, color):
"""
Command 0x07
sets all lights in the series starting from "startId" to "endId" to "color"
Data:
[0x07][startId][length][r][g][b]
"""
buff = bytearray()
buff.append(LightProtocolCommand.SetSeries)
buff.extend(struct.pack('<H', startId))
buff.extend(st... | [
"def",
"setSeries",
"(",
"self",
",",
"startId",
",",
"length",
",",
"color",
")",
":",
"buff",
"=",
"bytearray",
"(",
")",
"buff",
".",
"append",
"(",
"LightProtocolCommand",
".",
"SetSeries",
")",
"buff",
".",
"extend",
"(",
"struct",
".",
"pack",
"(... | Command 0x07
sets all lights in the series starting from "startId" to "endId" to "color"
Data:
[0x07][startId][length][r][g][b] | [
"Command",
"0x07",
"sets",
"all",
"lights",
"in",
"the",
"series",
"starting",
"from",
"startId",
"to",
"endId",
"to",
"color"
] | train | https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L192-L207 |
tripzero/python-photons | photons/lightprotocol.py | LightProtocol.setAllColor | def setAllColor(self, color):
"""
Command: 0x06
sets all colors in the array
Data:
[Command][r][g][b]
"""
header = bytearray()
header.append(LightProtocolCommand.SetAllColor)
light = bytearray()
light.extend(color)
buff = header + light
return self.send(buff) | python | def setAllColor(self, color):
"""
Command: 0x06
sets all colors in the array
Data:
[Command][r][g][b]
"""
header = bytearray()
header.append(LightProtocolCommand.SetAllColor)
light = bytearray()
light.extend(color)
buff = header + light
return self.send(buff) | [
"def",
"setAllColor",
"(",
"self",
",",
"color",
")",
":",
"header",
"=",
"bytearray",
"(",
")",
"header",
".",
"append",
"(",
"LightProtocolCommand",
".",
"SetAllColor",
")",
"light",
"=",
"bytearray",
"(",
")",
"light",
".",
"extend",
"(",
"color",
")"... | Command: 0x06
sets all colors in the array
Data:
[Command][r][g][b] | [
"Command",
":",
"0x06",
"sets",
"all",
"colors",
"in",
"the",
"array"
] | train | https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L210-L227 |
tripzero/python-photons | photons/lightprotocol.py | LightProtocol.clear | def clear(self):
"""
Command: 0x03
clear all leds
Data:
[Command]
"""
header = bytearray()
header.append(LightProtocolCommand.Clear)
return self.send(header) | python | def clear(self):
"""
Command: 0x03
clear all leds
Data:
[Command]
"""
header = bytearray()
header.append(LightProtocolCommand.Clear)
return self.send(header) | [
"def",
"clear",
"(",
"self",
")",
":",
"header",
"=",
"bytearray",
"(",
")",
"header",
".",
"append",
"(",
"LightProtocolCommand",
".",
"Clear",
")",
"return",
"self",
".",
"send",
"(",
"header",
")"
] | Command: 0x03
clear all leds
Data:
[Command] | [
"Command",
":",
"0x03",
"clear",
"all",
"leds"
] | train | https://github.com/tripzero/python-photons/blob/e185bbb55881189c7deeb599384944e61cf6048d/photons/lightprotocol.py#L229-L241 |
dossier/dossier.models | dossier/models/web/routes.py | v1_fc_put | def v1_fc_put(request, response, store, kvlclient, tfidf, cid):
'''Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in t... | python | def v1_fc_put(request, response, store, kvlclient, tfidf, cid):
'''Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in t... | [
"def",
"v1_fc_put",
"(",
"request",
",",
"response",
",",
"store",
",",
"kvlclient",
",",
"tfidf",
",",
"cid",
")",
":",
"tfidf",
"=",
"tfidf",
"or",
"None",
"if",
"request",
".",
"headers",
".",
"get",
"(",
"'content-type'",
",",
"''",
")",
".",
"st... | Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the request
body serialized as JSON.
Alternatively, if the requ... | [
"Store",
"a",
"single",
"feature",
"collection",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L170-L219 |
dossier/dossier.models | dossier/models/web/routes.py | v1_suggest_get | def v1_suggest_get(request, response, tfidf, query):
'''Gather suggestions from various engines and within this dossier
stack instance and filter/rank them before sending to requestor.
'''
config = yakonfig.get_global_config('dossier.models')
suggest_services = config.get('suggest_services', [])
... | python | def v1_suggest_get(request, response, tfidf, query):
'''Gather suggestions from various engines and within this dossier
stack instance and filter/rank them before sending to requestor.
'''
config = yakonfig.get_global_config('dossier.models')
suggest_services = config.get('suggest_services', [])
... | [
"def",
"v1_suggest_get",
"(",
"request",
",",
"response",
",",
"tfidf",
",",
"query",
")",
":",
"config",
"=",
"yakonfig",
".",
"get_global_config",
"(",
"'dossier.models'",
")",
"suggest_services",
"=",
"config",
".",
"get",
"(",
"'suggest_services'",
",",
"[... | Gather suggestions from various engines and within this dossier
stack instance and filter/rank them before sending to requestor. | [
"Gather",
"suggestions",
"from",
"various",
"engines",
"and",
"within",
"this",
"dossier",
"stack",
"instance",
"and",
"filter",
"/",
"rank",
"them",
"before",
"sending",
"to",
"requestor",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L232-L273 |
dossier/dossier.models | dossier/models/web/routes.py | v0_highlighter_post | def v0_highlighter_post(request, response, tfidf, cid):
'''Obtain highlights for a document POSTed as the body, which is the
pre-design-thinking structure of the highlights API. See v1 below.
NB: This end point will soon be deleted.
The route for this endpoint is:
``POST /dossier/v0/highlighter/<... | python | def v0_highlighter_post(request, response, tfidf, cid):
'''Obtain highlights for a document POSTed as the body, which is the
pre-design-thinking structure of the highlights API. See v1 below.
NB: This end point will soon be deleted.
The route for this endpoint is:
``POST /dossier/v0/highlighter/<... | [
"def",
"v0_highlighter_post",
"(",
"request",
",",
"response",
",",
"tfidf",
",",
"cid",
")",
":",
"logger",
".",
"info",
"(",
"'got %r'",
",",
"cid",
")",
"tfidf",
"=",
"tfidf",
"or",
"None",
"content_type",
"=",
"request",
".",
"headers",
".",
"get",
... | Obtain highlights for a document POSTed as the body, which is the
pre-design-thinking structure of the highlights API. See v1 below.
NB: This end point will soon be deleted.
The route for this endpoint is:
``POST /dossier/v0/highlighter/<cid>``.
``content_id`` is the id to associate with the giv... | [
"Obtain",
"highlights",
"for",
"a",
"document",
"POSTed",
"as",
"the",
"body",
"which",
"is",
"the",
"pre",
"-",
"design",
"-",
"thinking",
"structure",
"of",
"the",
"highlights",
"API",
".",
"See",
"v1",
"below",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L289-L331 |
dossier/dossier.models | dossier/models/web/routes.py | v1_highlights_get | def v1_highlights_get(response, kvlclient, file_id_str, max_elapsed = 300):
'''Obtain highlights for a document POSTed previously to this end
point. See documentation for v1_highlights_post for further
details. If the `state` is still `pending` for more than
`max_elapsed` after the start of the `WorkU... | python | def v1_highlights_get(response, kvlclient, file_id_str, max_elapsed = 300):
'''Obtain highlights for a document POSTed previously to this end
point. See documentation for v1_highlights_post for further
details. If the `state` is still `pending` for more than
`max_elapsed` after the start of the `WorkU... | [
"def",
"v1_highlights_get",
"(",
"response",
",",
"kvlclient",
",",
"file_id_str",
",",
"max_elapsed",
"=",
"300",
")",
":",
"file_id",
"=",
"make_file_id",
"(",
"file_id_str",
")",
"kvlclient",
".",
"setup_namespace",
"(",
"highlights_kvlayer_tables",
")",
"paylo... | Obtain highlights for a document POSTed previously to this end
point. See documentation for v1_highlights_post for further
details. If the `state` is still `pending` for more than
`max_elapsed` after the start of the `WorkUnit`, then this reports
an error, although the `WorkUnit` may continue in the b... | [
"Obtain",
"highlights",
"for",
"a",
"document",
"POSTed",
"previously",
"to",
"this",
"end",
"point",
".",
"See",
"documentation",
"for",
"v1_highlights_post",
"for",
"further",
"details",
".",
"If",
"the",
"state",
"is",
"still",
"pending",
"for",
"more",
"th... | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L345-L393 |
dossier/dossier.models | dossier/models/web/routes.py | v1_highlights_post | def v1_highlights_post(request, response, kvlclient, tfidf,
min_delay=3, task_master=None):
'''Obtain highlights for a document POSTed inside a JSON object.
Get our Diffeo Highlighter browser extension here:
https://chrome.google.com/webstore/detail/jgfcplgdmjkdepnmbdkmgohaldaiplpo
... | python | def v1_highlights_post(request, response, kvlclient, tfidf,
min_delay=3, task_master=None):
'''Obtain highlights for a document POSTed inside a JSON object.
Get our Diffeo Highlighter browser extension here:
https://chrome.google.com/webstore/detail/jgfcplgdmjkdepnmbdkmgohaldaiplpo
... | [
"def",
"v1_highlights_post",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"tfidf",
",",
"min_delay",
"=",
"3",
",",
"task_master",
"=",
"None",
")",
":",
"tfidf",
"=",
"tfidf",
"or",
"None",
"content_type",
"=",
"request",
".",
"headers",
".",
... | Obtain highlights for a document POSTed inside a JSON object.
Get our Diffeo Highlighter browser extension here:
https://chrome.google.com/webstore/detail/jgfcplgdmjkdepnmbdkmgohaldaiplpo
While you're at it, pre-register for a beta account on
http://diffeo.com.
`min_delay` and `task_master` are u... | [
"Obtain",
"highlights",
"for",
"a",
"document",
"POSTed",
"inside",
"a",
"JSON",
"object",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L397-L689 |
dossier/dossier.models | dossier/models/web/routes.py | highlights_worker | def highlights_worker(work_unit):
'''coordinate worker wrapper around :func:`maybe_create_highlights`
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run `create_highlights` without global config')
web_conf = Config()
unitconf = wor... | python | def highlights_worker(work_unit):
'''coordinate worker wrapper around :func:`maybe_create_highlights`
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run `create_highlights` without global config')
web_conf = Config()
unitconf = wor... | [
"def",
"highlights_worker",
"(",
"work_unit",
")",
":",
"if",
"'config'",
"not",
"in",
"work_unit",
".",
"spec",
":",
"raise",
"coordinate",
".",
"exceptions",
".",
"ProgrammerError",
"(",
"'could not run `create_highlights` without global config'",
")",
"web_conf",
"... | coordinate worker wrapper around :func:`maybe_create_highlights` | [
"coordinate",
"worker",
"wrapper",
"around",
":",
"func",
":",
"maybe_create_highlights"
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L692-L723 |
dossier/dossier.models | dossier/models/web/routes.py | maybe_store_highlights | def maybe_store_highlights(file_id, data, tfidf, kvlclient):
'''wrapper around :func:`create_highlights` that stores the response
payload in the `kvlayer` table called `highlights` as a stored
value if data['store'] is `False`. This allows error values as
well as successful responses from :func:`create... | python | def maybe_store_highlights(file_id, data, tfidf, kvlclient):
'''wrapper around :func:`create_highlights` that stores the response
payload in the `kvlayer` table called `highlights` as a stored
value if data['store'] is `False`. This allows error values as
well as successful responses from :func:`create... | [
"def",
"maybe_store_highlights",
"(",
"file_id",
",",
"data",
",",
"tfidf",
",",
"kvlclient",
")",
":",
"payload",
"=",
"create_highlights",
"(",
"data",
",",
"tfidf",
")",
"if",
"data",
"[",
"'store'",
"]",
"is",
"True",
":",
"stored_payload",
"=",
"{",
... | wrapper around :func:`create_highlights` that stores the response
payload in the `kvlayer` table called `highlights` as a stored
value if data['store'] is `False`. This allows error values as
well as successful responses from :func:`create_highlights` to
both get stored. | [
"wrapper",
"around",
":",
"func",
":",
"create_highlights",
"that",
"stores",
"the",
"response",
"payload",
"in",
"the",
"kvlayer",
"table",
"called",
"highlights",
"as",
"a",
"stored",
"value",
"if",
"data",
"[",
"store",
"]",
"is",
"False",
".",
"This",
... | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L726-L741 |
dossier/dossier.models | dossier/models/web/routes.py | create_highlights | def create_highlights(data, tfidf):
'''compute highlights for `data`, store it in the store using
`kvlclient`, and return a `highlights` response payload.
'''
try:
fc = etl.create_fc_from_html(
data['content-location'], data['body'], tfidf=tfidf, encoding=None)
except Exception,... | python | def create_highlights(data, tfidf):
'''compute highlights for `data`, store it in the store using
`kvlclient`, and return a `highlights` response payload.
'''
try:
fc = etl.create_fc_from_html(
data['content-location'], data['body'], tfidf=tfidf, encoding=None)
except Exception,... | [
"def",
"create_highlights",
"(",
"data",
",",
"tfidf",
")",
":",
"try",
":",
"fc",
"=",
"etl",
".",
"create_fc_from_html",
"(",
"data",
"[",
"'content-location'",
"]",
",",
"data",
"[",
"'body'",
"]",
",",
"tfidf",
"=",
"tfidf",
",",
"encoding",
"=",
"... | compute highlights for `data`, store it in the store using
`kvlclient`, and return a `highlights` response payload. | [
"compute",
"highlights",
"for",
"data",
"store",
"it",
"in",
"the",
"store",
"using",
"kvlclient",
"and",
"return",
"a",
"highlights",
"response",
"payload",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L744-L798 |
dossier/dossier.models | dossier/models/web/routes.py | build_highlight_objects | def build_highlight_objects(html, highlights, uniformize_html=True):
'''converts a dict of pretty_name --> [tuple(string, score), ...] to
`Highlight` objects as specified above.
'''
if uniformize_html:
try:
html = uniform_html(html.encode('utf-8')).decode('utf-8')
except Exc... | python | def build_highlight_objects(html, highlights, uniformize_html=True):
'''converts a dict of pretty_name --> [tuple(string, score), ...] to
`Highlight` objects as specified above.
'''
if uniformize_html:
try:
html = uniform_html(html.encode('utf-8')).decode('utf-8')
except Exc... | [
"def",
"build_highlight_objects",
"(",
"html",
",",
"highlights",
",",
"uniformize_html",
"=",
"True",
")",
":",
"if",
"uniformize_html",
":",
"try",
":",
"html",
"=",
"uniform_html",
"(",
"html",
".",
"encode",
"(",
"'utf-8'",
")",
")",
".",
"decode",
"("... | converts a dict of pretty_name --> [tuple(string, score), ...] to
`Highlight` objects as specified above. | [
"converts",
"a",
"dict",
"of",
"pretty_name",
"--",
">",
"[",
"tuple",
"(",
"string",
"score",
")",
"...",
"]",
"to",
"Highlight",
"objects",
"as",
"specified",
"above",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L801-L832 |
dossier/dossier.models | dossier/models/web/routes.py | make_xpath_ranges | def make_xpath_ranges(html, phrase):
'''Given a HTML string and a `phrase`, build a regex to find offsets
for the phrase, and then build a list of `XPathRange` objects for
it. If this fails, return empty list.
'''
if not html:
return []
if not isinstance(phrase, unicode):
try:
... | python | def make_xpath_ranges(html, phrase):
'''Given a HTML string and a `phrase`, build a regex to find offsets
for the phrase, and then build a list of `XPathRange` objects for
it. If this fails, return empty list.
'''
if not html:
return []
if not isinstance(phrase, unicode):
try:
... | [
"def",
"make_xpath_ranges",
"(",
"html",
",",
"phrase",
")",
":",
"if",
"not",
"html",
":",
"return",
"[",
"]",
"if",
"not",
"isinstance",
"(",
"phrase",
",",
"unicode",
")",
":",
"try",
":",
"phrase",
"=",
"phrase",
".",
"decode",
"(",
"'utf8'",
")"... | Given a HTML string and a `phrase`, build a regex to find offsets
for the phrase, and then build a list of `XPathRange` objects for
it. If this fails, return empty list. | [
"Given",
"a",
"HTML",
"string",
"and",
"a",
"phrase",
"build",
"a",
"regex",
"to",
"find",
"offsets",
"for",
"the",
"phrase",
"and",
"then",
"build",
"a",
"list",
"of",
"XPathRange",
"objects",
"for",
"it",
".",
"If",
"this",
"fails",
"return",
"empty",
... | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/web/routes.py#L835-L871 |
callowayproject/Transmogrify | transmogrify/core.py | Transmogrify.save | def save(self):
"""
Apply a series of actions from a set of (action, arg) tuples, probably
as parsed from a URL. Each action is a code into PROCESSORS.
Then save the mogrified image.
"""
from settings import PROCESSORS
from .filesystem import makedirs
if... | python | def save(self):
"""
Apply a series of actions from a set of (action, arg) tuples, probably
as parsed from a URL. Each action is a code into PROCESSORS.
Then save the mogrified image.
"""
from settings import PROCESSORS
from .filesystem import makedirs
if... | [
"def",
"save",
"(",
"self",
")",
":",
"from",
"settings",
"import",
"PROCESSORS",
"from",
".",
"filesystem",
"import",
"makedirs",
"if",
"self",
".",
"im",
"is",
"None",
":",
"# If we got here something very strange is going on that I can't even",
"# predict.",
"retur... | Apply a series of actions from a set of (action, arg) tuples, probably
as parsed from a URL. Each action is a code into PROCESSORS.
Then save the mogrified image. | [
"Apply",
"a",
"series",
"of",
"actions",
"from",
"a",
"set",
"of",
"(",
"action",
"arg",
")",
"tuples",
"probably",
"as",
"parsed",
"from",
"a",
"URL",
".",
"Each",
"action",
"is",
"a",
"code",
"into",
"PROCESSORS",
"."
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/core.py#L42-L91 |
lwcook/horsetail-matching | horsetailmatching/surrogates.py | eval_poly | def eval_poly(uvec, nvec, Jvec):
'''Evaluate multi-dimensional polynomials through tensor multiplication.
:param list uvec: vector value of the uncertain parameters at which to evaluate the
polynomial
:param list nvec: order in each dimension at which to evaluate the polynomial
:param list Jv... | python | def eval_poly(uvec, nvec, Jvec):
'''Evaluate multi-dimensional polynomials through tensor multiplication.
:param list uvec: vector value of the uncertain parameters at which to evaluate the
polynomial
:param list nvec: order in each dimension at which to evaluate the polynomial
:param list Jv... | [
"def",
"eval_poly",
"(",
"uvec",
",",
"nvec",
",",
"Jvec",
")",
":",
"us",
"=",
"_makeIter",
"(",
"uvec",
")",
"ns",
"=",
"_makeIter",
"(",
"nvec",
")",
"Js",
"=",
"_makeIter",
"(",
"Jvec",
")",
"return",
"np",
".",
"prod",
"(",
"[",
"_eval_poly_1D... | Evaluate multi-dimensional polynomials through tensor multiplication.
:param list uvec: vector value of the uncertain parameters at which to evaluate the
polynomial
:param list nvec: order in each dimension at which to evaluate the polynomial
:param list Jvec: Jacobi matrix of each dimension's 1D... | [
"Evaluate",
"multi",
"-",
"dimensional",
"polynomials",
"through",
"tensor",
"multiplication",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L186-L204 |
lwcook/horsetail-matching | horsetailmatching/surrogates.py | PolySurrogate.surrogate | def surrogate(self, u_sparse, q_sparse):
'''Combines the train and predict methods to create a surrogate
model function fitted to the input/output combinations given in
u_sparse and q_sparse.
:param numpy.ndarray u_sparse: input values at which the output
values are obtained... | python | def surrogate(self, u_sparse, q_sparse):
'''Combines the train and predict methods to create a surrogate
model function fitted to the input/output combinations given in
u_sparse and q_sparse.
:param numpy.ndarray u_sparse: input values at which the output
values are obtained... | [
"def",
"surrogate",
"(",
"self",
",",
"u_sparse",
",",
"q_sparse",
")",
":",
"self",
".",
"train",
"(",
"q_sparse",
")",
"def",
"model",
"(",
"u",
")",
":",
"return",
"self",
".",
"predict",
"(",
"u",
")",
"return",
"model"
] | Combines the train and predict methods to create a surrogate
model function fitted to the input/output combinations given in
u_sparse and q_sparse.
:param numpy.ndarray u_sparse: input values at which the output
values are obtained. Must be the same as the qaudrature
po... | [
"Combines",
"the",
"train",
"and",
"predict",
"methods",
"to",
"create",
"a",
"surrogate",
"model",
"function",
"fitted",
"to",
"the",
"input",
"/",
"output",
"combinations",
"given",
"in",
"u_sparse",
"and",
"q_sparse",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L43-L70 |
lwcook/horsetail-matching | horsetailmatching/surrogates.py | PolySurrogate.predict | def predict(self, u):
'''Predicts the output value at u from the fitted polynomial expansion.
Therefore the method train() must be called first.
:param numpy.ndarray u: input value at which to predict the output.
:return: q_approx - the predicted value of the output at u
:rtyp... | python | def predict(self, u):
'''Predicts the output value at u from the fitted polynomial expansion.
Therefore the method train() must be called first.
:param numpy.ndarray u: input value at which to predict the output.
:return: q_approx - the predicted value of the output at u
:rtyp... | [
"def",
"predict",
"(",
"self",
",",
"u",
")",
":",
"y",
",",
"ysub",
"=",
"0",
",",
"np",
".",
"zeros",
"(",
"self",
".",
"N_poly",
")",
"for",
"ip",
"in",
"range",
"(",
"self",
".",
"N_poly",
")",
":",
"inds",
"=",
"tuple",
"(",
"self",
".",... | Predicts the output value at u from the fitted polynomial expansion.
Therefore the method train() must be called first.
:param numpy.ndarray u: input value at which to predict the output.
:return: q_approx - the predicted value of the output at u
:rtype: float
*Sample Usage*:... | [
"Predicts",
"the",
"output",
"value",
"at",
"u",
"from",
"the",
"fitted",
"polynomial",
"expansion",
".",
"Therefore",
"the",
"method",
"train",
"()",
"must",
"be",
"called",
"first",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L72-L98 |
lwcook/horsetail-matching | horsetailmatching/surrogates.py | PolySurrogate.train | def train(self, ftrain):
'''Trains the polynomial expansion.
:param numpy.ndarray/function ftrain: output values corresponding to the
quadrature points given by the getQuadraturePoints method to
which the expansion should be trained. Or a function that should be evaluated
... | python | def train(self, ftrain):
'''Trains the polynomial expansion.
:param numpy.ndarray/function ftrain: output values corresponding to the
quadrature points given by the getQuadraturePoints method to
which the expansion should be trained. Or a function that should be evaluated
... | [
"def",
"train",
"(",
"self",
",",
"ftrain",
")",
":",
"self",
".",
"coeffs",
"=",
"0",
"*",
"self",
".",
"coeffs",
"upoints",
",",
"wpoints",
"=",
"self",
".",
"getQuadraturePointsAndWeights",
"(",
")",
"try",
":",
"fpoints",
"=",
"[",
"ftrain",
"(",
... | Trains the polynomial expansion.
:param numpy.ndarray/function ftrain: output values corresponding to the
quadrature points given by the getQuadraturePoints method to
which the expansion should be trained. Or a function that should be evaluated
at the quadrature points to gi... | [
"Trains",
"the",
"polynomial",
"expansion",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L100-L138 |
lwcook/horsetail-matching | horsetailmatching/surrogates.py | PolySurrogate.getQuadraturePointsAndWeights | def getQuadraturePointsAndWeights(self):
'''Gets the quadrature points and weights for gaussian quadrature
integration of inner products from the definition of the polynomials in
each dimension.
:return: (u_points, w_points) - np.ndarray of shape
(num_polynomials, num_dimen... | python | def getQuadraturePointsAndWeights(self):
'''Gets the quadrature points and weights for gaussian quadrature
integration of inner products from the definition of the polynomials in
each dimension.
:return: (u_points, w_points) - np.ndarray of shape
(num_polynomials, num_dimen... | [
"def",
"getQuadraturePointsAndWeights",
"(",
"self",
")",
":",
"qw_list",
",",
"qp_list",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"ii",
"in",
"np",
".",
"arange",
"(",
"len",
"(",
"self",
".",
"J_list",
")",
")",
":",
"d",
",",
"Q",
"=",
"np",
".",
... | Gets the quadrature points and weights for gaussian quadrature
integration of inner products from the definition of the polynomials in
each dimension.
:return: (u_points, w_points) - np.ndarray of shape
(num_polynomials, num_dimensions) and a np.ndarray of size
(num_pol... | [
"Gets",
"the",
"quadrature",
"points",
"and",
"weights",
"for",
"gaussian",
"quadrature",
"integration",
"of",
"inner",
"products",
"from",
"the",
"definition",
"of",
"the",
"polynomials",
"in",
"each",
"dimension",
"."
] | train | https://github.com/lwcook/horsetail-matching/blob/f3d5f8d01249debbca978f412ce4eae017458119/horsetailmatching/surrogates.py#L140-L169 |
kolypto/py-exdoc | exdoc/sa/__init__.py | _model_columns | def _model_columns(ins):
""" Get columns info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaColumnDoc]
"""
columns = []
for c in ins.column_attrs:
# Skip protected
if c.key.startswith('_'):
continue
# Collect
columns.append(SaColumnDoc(
... | python | def _model_columns(ins):
""" Get columns info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaColumnDoc]
"""
columns = []
for c in ins.column_attrs:
# Skip protected
if c.key.startswith('_'):
continue
# Collect
columns.append(SaColumnDoc(
... | [
"def",
"_model_columns",
"(",
"ins",
")",
":",
"columns",
"=",
"[",
"]",
"for",
"c",
"in",
"ins",
".",
"column_attrs",
":",
"# Skip protected",
"if",
"c",
".",
"key",
".",
"startswith",
"(",
"'_'",
")",
":",
"continue",
"# Collect",
"columns",
".",
"ap... | Get columns info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaColumnDoc] | [
"Get",
"columns",
"info"
] | train | https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L55-L74 |
kolypto/py-exdoc | exdoc/sa/__init__.py | _model_foreign | def _model_foreign(ins):
""" Get foreign keys info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaForeignkeyDoc]
"""
fks = []
for t in ins.tables:
fks.extend([
SaForeignkeyDoc(
key=fk.column.key,
target=fk.target_fullname,
... | python | def _model_foreign(ins):
""" Get foreign keys info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaForeignkeyDoc]
"""
fks = []
for t in ins.tables:
fks.extend([
SaForeignkeyDoc(
key=fk.column.key,
target=fk.target_fullname,
... | [
"def",
"_model_foreign",
"(",
"ins",
")",
":",
"fks",
"=",
"[",
"]",
"for",
"t",
"in",
"ins",
".",
"tables",
":",
"fks",
".",
"extend",
"(",
"[",
"SaForeignkeyDoc",
"(",
"key",
"=",
"fk",
".",
"column",
".",
"key",
",",
"target",
"=",
"fk",
".",
... | Get foreign keys info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaForeignkeyDoc] | [
"Get",
"foreign",
"keys",
"info"
] | train | https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L86-L102 |
kolypto/py-exdoc | exdoc/sa/__init__.py | _model_unique | def _model_unique(ins):
""" Get unique constraints info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[tuple[str]]
"""
unique = []
for t in ins.tables:
for c in t.constraints:
if isinstance(c, UniqueConstraint):
unique.append(tuple(col.key for col in c.... | python | def _model_unique(ins):
""" Get unique constraints info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[tuple[str]]
"""
unique = []
for t in ins.tables:
for c in t.constraints:
if isinstance(c, UniqueConstraint):
unique.append(tuple(col.key for col in c.... | [
"def",
"_model_unique",
"(",
"ins",
")",
":",
"unique",
"=",
"[",
"]",
"for",
"t",
"in",
"ins",
".",
"tables",
":",
"for",
"c",
"in",
"t",
".",
"constraints",
":",
"if",
"isinstance",
"(",
"c",
",",
"UniqueConstraint",
")",
":",
"unique",
".",
"app... | Get unique constraints info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[tuple[str]] | [
"Get",
"unique",
"constraints",
"info"
] | train | https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L105-L116 |
kolypto/py-exdoc | exdoc/sa/__init__.py | _model_relations | def _model_relations(ins):
""" Get relationships info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaRelationshipDoc]
"""
relations = []
for r in ins.relationships:
# Hard times with the foreign model :)
if isinstance(r.argument, Mapper):
model_name = r.argum... | python | def _model_relations(ins):
""" Get relationships info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaRelationshipDoc]
"""
relations = []
for r in ins.relationships:
# Hard times with the foreign model :)
if isinstance(r.argument, Mapper):
model_name = r.argum... | [
"def",
"_model_relations",
"(",
"ins",
")",
":",
"relations",
"=",
"[",
"]",
"for",
"r",
"in",
"ins",
".",
"relationships",
":",
"# Hard times with the foreign model :)",
"if",
"isinstance",
"(",
"r",
".",
"argument",
",",
"Mapper",
")",
":",
"model_name",
"... | Get relationships info
:type ins: sqlalchemy.orm.mapper.Mapper
:rtype: list[SaRelationshipDoc] | [
"Get",
"relationships",
"info"
] | train | https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L119-L143 |
kolypto/py-exdoc | exdoc/sa/__init__.py | doc | def doc(model):
""" Get documentation object for an SqlAlchemy model
:param model: Model
:type model: sqlalchemy.ext.declarative.DeclarativeBase
:rtype: SaModelDoc
"""
ins = inspect(model)
return SaModelDoc(
name=model.__name__,
table=[t.name for t in ins.tables],
d... | python | def doc(model):
""" Get documentation object for an SqlAlchemy model
:param model: Model
:type model: sqlalchemy.ext.declarative.DeclarativeBase
:rtype: SaModelDoc
"""
ins = inspect(model)
return SaModelDoc(
name=model.__name__,
table=[t.name for t in ins.tables],
d... | [
"def",
"doc",
"(",
"model",
")",
":",
"ins",
"=",
"inspect",
"(",
"model",
")",
"return",
"SaModelDoc",
"(",
"name",
"=",
"model",
".",
"__name__",
",",
"table",
"=",
"[",
"t",
".",
"name",
"for",
"t",
"in",
"ins",
".",
"tables",
"]",
",",
"doc",... | Get documentation object for an SqlAlchemy model
:param model: Model
:type model: sqlalchemy.ext.declarative.DeclarativeBase
:rtype: SaModelDoc | [
"Get",
"documentation",
"object",
"for",
"an",
"SqlAlchemy",
"model"
] | train | https://github.com/kolypto/py-exdoc/blob/516526c01c203271410e7d7340024ef9f0bfa46a/exdoc/sa/__init__.py#L146-L164 |
minorg/pastpy | py/src/pastpy/gen/database/impl/dbf/dbf_database_configuration.py | DbfDatabaseConfiguration.write | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.dbf_database_configuration.DbfDatabaseConfiguration
'''
oprot.write_struct_begi... | python | def write(self, oprot):
'''
Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.dbf_database_configuration.DbfDatabaseConfiguration
'''
oprot.write_struct_begi... | [
"def",
"write",
"(",
"self",
",",
"oprot",
")",
":",
"oprot",
".",
"write_struct_begin",
"(",
"'DbfDatabaseConfiguration'",
")",
"if",
"self",
".",
"pp_images_dir_path",
"is",
"not",
"None",
":",
"oprot",
".",
"write_field_begin",
"(",
"name",
"=",
"'pp_images... | Write this object to the given output protocol and return self.
:type oprot: thryft.protocol._output_protocol._OutputProtocol
:rtype: pastpy.gen.database.impl.dbf.dbf_database_configuration.DbfDatabaseConfiguration | [
"Write",
"this",
"object",
"to",
"the",
"given",
"output",
"protocol",
"and",
"return",
"self",
"."
] | train | https://github.com/minorg/pastpy/blob/7d5d6d511629481850216565e7451b5dcb8027a9/py/src/pastpy/gen/database/impl/dbf/dbf_database_configuration.py#L264-L293 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/generate/utility.py | GetModuleBaseNameFromWSDL | def GetModuleBaseNameFromWSDL(wsdl):
"""By default try to construct a reasonable base name for all
generated modules. Otherwise return None.
"""
base_name = wsdl.name or wsdl.services[0].name
base_name = SplitQName(base_name)[1]
if base_name is None:
return None
return NCName_to_Mo... | python | def GetModuleBaseNameFromWSDL(wsdl):
"""By default try to construct a reasonable base name for all
generated modules. Otherwise return None.
"""
base_name = wsdl.name or wsdl.services[0].name
base_name = SplitQName(base_name)[1]
if base_name is None:
return None
return NCName_to_Mo... | [
"def",
"GetModuleBaseNameFromWSDL",
"(",
"wsdl",
")",
":",
"base_name",
"=",
"wsdl",
".",
"name",
"or",
"wsdl",
".",
"services",
"[",
"0",
"]",
".",
"name",
"base_name",
"=",
"SplitQName",
"(",
"base_name",
")",
"[",
"1",
"]",
"if",
"base_name",
"is",
... | By default try to construct a reasonable base name for all
generated modules. Otherwise return None. | [
"By",
"default",
"try",
"to",
"construct",
"a",
"reasonable",
"base",
"name",
"for",
"all",
"generated",
"modules",
".",
"Otherwise",
"return",
"None",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/generate/utility.py#L26-L34 |
jeroyang/txttk | txttk/retools.py | condense | def condense(ss_unescaped):
"""
Given multiple strings, returns a compressed regular expression just
for these strings
>>> condense(['she', 'he', 'her', 'hemoglobin'])
'he(moglobin|r)?|she'
"""
def estimated_len(longg, short):
return (3
+ len(short)
+... | python | def condense(ss_unescaped):
"""
Given multiple strings, returns a compressed regular expression just
for these strings
>>> condense(['she', 'he', 'her', 'hemoglobin'])
'he(moglobin|r)?|she'
"""
def estimated_len(longg, short):
return (3
+ len(short)
+... | [
"def",
"condense",
"(",
"ss_unescaped",
")",
":",
"def",
"estimated_len",
"(",
"longg",
",",
"short",
")",
":",
"return",
"(",
"3",
"+",
"len",
"(",
"short",
")",
"+",
"sum",
"(",
"map",
"(",
"len",
",",
"longg",
")",
")",
"-",
"len",
"(",
"longg... | Given multiple strings, returns a compressed regular expression just
for these strings
>>> condense(['she', 'he', 'her', 'hemoglobin'])
'he(moglobin|r)?|she' | [
"Given",
"multiple",
"strings",
"returns",
"a",
"compressed",
"regular",
"expression",
"just",
"for",
"these",
"strings"
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L10-L73 |
jeroyang/txttk | txttk/retools.py | is_solid | def is_solid(regex):
"""
Check the given regular expression is solid.
>>> is_solid(r'a')
True
>>> is_solid(r'[ab]')
True
>>> is_solid(r'(a|b|c)')
True
>>> is_solid(r'(a|b|c)?')
True
>>> is_solid(r'(a|b)(c)')
False
>>> is_solid(r'(a|b)(c)?')
False
"""
sha... | python | def is_solid(regex):
"""
Check the given regular expression is solid.
>>> is_solid(r'a')
True
>>> is_solid(r'[ab]')
True
>>> is_solid(r'(a|b|c)')
True
>>> is_solid(r'(a|b|c)?')
True
>>> is_solid(r'(a|b)(c)')
False
>>> is_solid(r'(a|b)(c)?')
False
"""
sha... | [
"def",
"is_solid",
"(",
"regex",
")",
":",
"shape",
"=",
"re",
".",
"sub",
"(",
"r'(\\\\.|[^\\[\\]\\(\\)\\|\\?\\+\\*])'",
",",
"'#'",
",",
"regex",
")",
"skeleton",
"=",
"shape",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
"if",
"len",
"(",
"shape",
")... | Check the given regular expression is solid.
>>> is_solid(r'a')
True
>>> is_solid(r'[ab]')
True
>>> is_solid(r'(a|b|c)')
True
>>> is_solid(r'(a|b|c)?')
True
>>> is_solid(r'(a|b)(c)')
False
>>> is_solid(r'(a|b)(c)?')
False | [
"Check",
"the",
"given",
"regular",
"expression",
"is",
"solid",
"."
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L75-L104 |
jeroyang/txttk | txttk/retools.py | danger_unpack | def danger_unpack(regex):
"""
Remove the outermost parens
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'abc'
>>> unpack(r'[abc]')
'[abc]'
"""
if is_packed(regex):
return re.sub(r'^\((\?(:|P<.*?>))?(?P<content>.*?)\)$', r'\g... | python | def danger_unpack(regex):
"""
Remove the outermost parens
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'abc'
>>> unpack(r'[abc]')
'[abc]'
"""
if is_packed(regex):
return re.sub(r'^\((\?(:|P<.*?>))?(?P<content>.*?)\)$', r'\g... | [
"def",
"danger_unpack",
"(",
"regex",
")",
":",
"if",
"is_packed",
"(",
"regex",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'^\\((\\?(:|P<.*?>))?(?P<content>.*?)\\)$'",
",",
"r'\\g<content>'",
",",
"regex",
")",
"else",
":",
"return",
"regex"
] | Remove the outermost parens
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'abc'
>>> unpack(r'[abc]')
'[abc]' | [
"Remove",
"the",
"outermost",
"parens"
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L122-L139 |
jeroyang/txttk | txttk/retools.py | unpack | def unpack(regex):
"""
Remove the outermost parens, keep the (?P...) one
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'(?P<xyz>abc)'
>>> unpack(r'[abc]')
'[abc]'
"""
if is_packed(regex) and not regex.startswith('(?P<'):
retu... | python | def unpack(regex):
"""
Remove the outermost parens, keep the (?P...) one
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'(?P<xyz>abc)'
>>> unpack(r'[abc]')
'[abc]'
"""
if is_packed(regex) and not regex.startswith('(?P<'):
retu... | [
"def",
"unpack",
"(",
"regex",
")",
":",
"if",
"is_packed",
"(",
"regex",
")",
"and",
"not",
"regex",
".",
"startswith",
"(",
"'(?P<'",
")",
":",
"return",
"re",
".",
"sub",
"(",
"r'^\\((\\?:)?(?P<content>.*?)\\)$'",
",",
"r'\\g<content>'",
",",
"regex",
"... | Remove the outermost parens, keep the (?P...) one
>>> unpack(r'(abc)')
'abc'
>>> unpack(r'(?:abc)')
'abc'
>>> unpack(r'(?P<xyz>abc)')
'(?P<xyz>abc)'
>>> unpack(r'[abc]')
'[abc]' | [
"Remove",
"the",
"outermost",
"parens",
"keep",
"the",
"(",
"?P",
"...",
")",
"one"
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L141-L157 |
jeroyang/txttk | txttk/retools.py | parallel | def parallel(regex_list, sort=False):
"""
Join the given regexes using r'|'
if the sort=True, regexes will be sorted by lenth before processing
>>> parallel([r'abc', r'def'])
'abc|def'
>>> parallel([r'abc', r'd|ef'])
'abc|def'
>>> parallel([r'abc', r'(d|ef)'])
'abc|d|ef'
>>>... | python | def parallel(regex_list, sort=False):
"""
Join the given regexes using r'|'
if the sort=True, regexes will be sorted by lenth before processing
>>> parallel([r'abc', r'def'])
'abc|def'
>>> parallel([r'abc', r'd|ef'])
'abc|def'
>>> parallel([r'abc', r'(d|ef)'])
'abc|d|ef'
>>>... | [
"def",
"parallel",
"(",
"regex_list",
",",
"sort",
"=",
"False",
")",
":",
"if",
"sort",
":",
"regex_list",
"=",
"sorted",
"(",
"regex_list",
",",
"key",
"=",
"len",
",",
"reverse",
"=",
"True",
")",
"return",
"'|'",
".",
"join",
"(",
"[",
"unpack",
... | Join the given regexes using r'|'
if the sort=True, regexes will be sorted by lenth before processing
>>> parallel([r'abc', r'def'])
'abc|def'
>>> parallel([r'abc', r'd|ef'])
'abc|def'
>>> parallel([r'abc', r'(d|ef)'])
'abc|d|ef'
>>> parallel([r'abc', r'defg'])
'defg|abc' | [
"Join",
"the",
"given",
"regexes",
"using",
"r",
"|",
"if",
"the",
"sort",
"=",
"True",
"regexes",
"will",
"be",
"sorted",
"by",
"lenth",
"before",
"processing",
">>>",
"parallel",
"(",
"[",
"r",
"abc",
"r",
"def",
"]",
")",
"abc|def",
">>>",
"parallel... | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L159-L175 |
jeroyang/txttk | txttk/retools.py | nocatch | def nocatch(regex):
"""
Put on a pair of parens (with no catch tag) outside the regex,
if the regex is not yet packed;
modified the outmost parens by adding nocatch tag
"""
if is_solid(regex) and not is_packed(regex):
return regex
else:
return '(?:{})'.format(danger_unpack(re... | python | def nocatch(regex):
"""
Put on a pair of parens (with no catch tag) outside the regex,
if the regex is not yet packed;
modified the outmost parens by adding nocatch tag
"""
if is_solid(regex) and not is_packed(regex):
return regex
else:
return '(?:{})'.format(danger_unpack(re... | [
"def",
"nocatch",
"(",
"regex",
")",
":",
"if",
"is_solid",
"(",
"regex",
")",
"and",
"not",
"is_packed",
"(",
"regex",
")",
":",
"return",
"regex",
"else",
":",
"return",
"'(?:{})'",
".",
"format",
"(",
"danger_unpack",
"(",
"regex",
")",
")"
] | Put on a pair of parens (with no catch tag) outside the regex,
if the regex is not yet packed;
modified the outmost parens by adding nocatch tag | [
"Put",
"on",
"a",
"pair",
"of",
"parens",
"(",
"with",
"no",
"catch",
"tag",
")",
"outside",
"the",
"regex",
"if",
"the",
"regex",
"is",
"not",
"yet",
"packed",
";",
"modified",
"the",
"outmost",
"parens",
"by",
"adding",
"nocatch",
"tag"
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L177-L186 |
jeroyang/txttk | txttk/retools.py | concat | def concat(regex_list):
"""
Concat multiple regular expression into one, if the given regular expression is not packed,
a pair of paren will be add.
>>> reg_1 = r'a|b'
>>> reg_2 = r'(c|d|e)'
>>> concat([reg_1, reg2])
(a|b)(c|d|e)
"""
output_list = []
for regex in regex_list:
... | python | def concat(regex_list):
"""
Concat multiple regular expression into one, if the given regular expression is not packed,
a pair of paren will be add.
>>> reg_1 = r'a|b'
>>> reg_2 = r'(c|d|e)'
>>> concat([reg_1, reg2])
(a|b)(c|d|e)
"""
output_list = []
for regex in regex_list:
... | [
"def",
"concat",
"(",
"regex_list",
")",
":",
"output_list",
"=",
"[",
"]",
"for",
"regex",
"in",
"regex_list",
":",
"output_list",
".",
"append",
"(",
"consolidate",
"(",
"regex",
")",
")",
"return",
"r''",
".",
"join",
"(",
"output_list",
")"
] | Concat multiple regular expression into one, if the given regular expression is not packed,
a pair of paren will be add.
>>> reg_1 = r'a|b'
>>> reg_2 = r'(c|d|e)'
>>> concat([reg_1, reg2])
(a|b)(c|d|e) | [
"Concat",
"multiple",
"regular",
"expression",
"into",
"one",
"if",
"the",
"given",
"regular",
"expression",
"is",
"not",
"packed",
"a",
"pair",
"of",
"paren",
"will",
"be",
"add",
"."
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/retools.py#L188-L202 |
jic-dtool/dtool-config | dtool_config/utils.py | set_cache | def set_cache(config_fpath, cache_dir):
"""Write the cache directory to the dtool config file.
:param config_fpath: path to the dtool config file
:param cache_dir: the path to the dtool cache direcotory
"""
cache_dir = os.path.abspath(cache_dir)
return write_config_value_to_file(
CACHE_... | python | def set_cache(config_fpath, cache_dir):
"""Write the cache directory to the dtool config file.
:param config_fpath: path to the dtool config file
:param cache_dir: the path to the dtool cache direcotory
"""
cache_dir = os.path.abspath(cache_dir)
return write_config_value_to_file(
CACHE_... | [
"def",
"set_cache",
"(",
"config_fpath",
",",
"cache_dir",
")",
":",
"cache_dir",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"cache_dir",
")",
"return",
"write_config_value_to_file",
"(",
"CACHE_DIRECTORY_KEY",
",",
"cache_dir",
",",
"config_fpath",
")"
] | Write the cache directory to the dtool config file.
:param config_fpath: path to the dtool config file
:param cache_dir: the path to the dtool cache direcotory | [
"Write",
"the",
"cache",
"directory",
"to",
"the",
"dtool",
"config",
"file",
"."
] | train | https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L167-L178 |
jic-dtool/dtool-config | dtool_config/utils.py | set_azure_secret_access_key | def set_azure_secret_access_key(config_fpath, container, az_secret_access_key):
"""Write the ECS access key id to the dtool config file.
:param config_fpath: path to the dtool config file
:param container: azure storage container name
:param az_secret_access_key: azure secret access key for the contain... | python | def set_azure_secret_access_key(config_fpath, container, az_secret_access_key):
"""Write the ECS access key id to the dtool config file.
:param config_fpath: path to the dtool config file
:param container: azure storage container name
:param az_secret_access_key: azure secret access key for the contain... | [
"def",
"set_azure_secret_access_key",
"(",
"config_fpath",
",",
"container",
",",
"az_secret_access_key",
")",
":",
"key",
"=",
"AZURE_KEY_PREFIX",
"+",
"container",
"return",
"write_config_value_to_file",
"(",
"key",
",",
"az_secret_access_key",
",",
"config_fpath",
")... | Write the ECS access key id to the dtool config file.
:param config_fpath: path to the dtool config file
:param container: azure storage container name
:param az_secret_access_key: azure secret access key for the container | [
"Write",
"the",
"ECS",
"access",
"key",
"id",
"to",
"the",
"dtool",
"config",
"file",
"."
] | train | https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L192-L200 |
jic-dtool/dtool-config | dtool_config/utils.py | list_azure_containers | def list_azure_containers(config_fpath):
"""List the azure storage containers in the config file.
:param config_fpath: path to the dtool config file
:returns: the list of azure storage container names
"""
config_content = _get_config_dict_from_file(config_fpath)
az_container_names = []
for ... | python | def list_azure_containers(config_fpath):
"""List the azure storage containers in the config file.
:param config_fpath: path to the dtool config file
:returns: the list of azure storage container names
"""
config_content = _get_config_dict_from_file(config_fpath)
az_container_names = []
for ... | [
"def",
"list_azure_containers",
"(",
"config_fpath",
")",
":",
"config_content",
"=",
"_get_config_dict_from_file",
"(",
"config_fpath",
")",
"az_container_names",
"=",
"[",
"]",
"for",
"key",
"in",
"config_content",
".",
"keys",
"(",
")",
":",
"if",
"key",
".",... | List the azure storage containers in the config file.
:param config_fpath: path to the dtool config file
:returns: the list of azure storage container names | [
"List",
"the",
"azure",
"storage",
"containers",
"in",
"the",
"config",
"file",
"."
] | train | https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/utils.py#L203-L215 |
voidpp/python-tools | voidpp_tools/config_loader.py | ConfigLoader.load | def load(self, filename, create = None, default_conf = {}):
"""Load the config file
Args:
filename (str): the filename of the config, without any path
create (str): if the config file not found, and this parameter is not None,
a config file will be crea... | python | def load(self, filename, create = None, default_conf = {}):
"""Load the config file
Args:
filename (str): the filename of the config, without any path
create (str): if the config file not found, and this parameter is not None,
a config file will be crea... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"create",
"=",
"None",
",",
"default_conf",
"=",
"{",
"}",
")",
":",
"filenames",
",",
"tries",
"=",
"self",
".",
"__search_config_files",
"(",
"filename",
")",
"if",
"len",
"(",
"filenames",
")",
":",
... | Load the config file
Args:
filename (str): the filename of the config, without any path
create (str): if the config file not found, and this parameter is not None,
a config file will be create with content of default_conf
default_conf (dict): conten... | [
"Load",
"the",
"config",
"file"
] | train | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/config_loader.py#L79-L106 |
voidpp/python-tools | voidpp_tools/config_loader.py | ConfigLoader.save | def save(self, data):
"""Save the config data
Args:
data: any serializable config data
Raises:
ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name,
or the data is not serializable or the loader i... | python | def save(self, data):
"""Save the config data
Args:
data: any serializable config data
Raises:
ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name,
or the data is not serializable or the loader i... | [
"def",
"save",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"__nested",
":",
"raise",
"ConfigLoaderException",
"(",
"\"Cannot save the config if the 'nested' paramter is True!\"",
")",
"if",
"self",
".",
"__loaded_config_file",
"is",
"None",
":",
"raise",
... | Save the config data
Args:
data: any serializable config data
Raises:
ConfigLoaderException: if the ConfigLoader.load not called, so there is no config file name,
or the data is not serializable or the loader is nested | [
"Save",
"the",
"config",
"data"
] | train | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/config_loader.py#L108-L128 |
matthewdeanmartin/jiggle_version | jiggle_version/utils.py | execute_get_text | def execute_get_text(command, raise_errors=False): # type: (str, bool) -> str
"""
Execute a shell commmand
:param command:
:return:
"""
try:
result = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
# print(result.decode())
except subprocess.CalledProce... | python | def execute_get_text(command, raise_errors=False): # type: (str, bool) -> str
"""
Execute a shell commmand
:param command:
:return:
"""
try:
result = subprocess.check_output(command, stderr=subprocess.STDOUT, shell=True)
# print(result.decode())
except subprocess.CalledProce... | [
"def",
"execute_get_text",
"(",
"command",
",",
"raise_errors",
"=",
"False",
")",
":",
"# type: (str, bool) -> str",
"try",
":",
"result",
"=",
"subprocess",
".",
"check_output",
"(",
"command",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
",",
"shell",
"... | Execute a shell commmand
:param command:
:return: | [
"Execute",
"a",
"shell",
"commmand",
":",
"param",
"command",
":",
":",
"return",
":"
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/utils.py#L61-L76 |
etcher-be/emiz | emiz/weather/avwx/avwx.py | AVWX.metar_to_speech | def metar_to_speech(metar: str) -> str:
"""
Creates a speakable text from a METAR
Args:
metar: METAR string to use
Returns: speakable METAR for TTS
"""
LOGGER.info('getting speech text from METAR: %s', metar)
metar_data, metar_units = emiz.avwx.meta... | python | def metar_to_speech(metar: str) -> str:
"""
Creates a speakable text from a METAR
Args:
metar: METAR string to use
Returns: speakable METAR for TTS
"""
LOGGER.info('getting speech text from METAR: %s', metar)
metar_data, metar_units = emiz.avwx.meta... | [
"def",
"metar_to_speech",
"(",
"metar",
":",
"str",
")",
"->",
"str",
":",
"LOGGER",
".",
"info",
"(",
"'getting speech text from METAR: %s'",
",",
"metar",
")",
"metar_data",
",",
"metar_units",
"=",
"emiz",
".",
"avwx",
".",
"metar",
".",
"parse_in",
"(",
... | Creates a speakable text from a METAR
Args:
metar: METAR string to use
Returns: speakable METAR for TTS | [
"Creates",
"a",
"speakable",
"text",
"from",
"a",
"METAR"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/weather/avwx/avwx.py#L22-L37 |
aykevl/reserved | names.py | names | def names():
'''
Lazy-load the tree of names, and return them in an object.
Of course, asterisks etc. cannot be resolved, you should use allowed() to
check for a valid name.
'''
global blacklist
if blacklist is None:
# not yet loaded
path = os.path.join(os.path.dirname(__file... | python | def names():
'''
Lazy-load the tree of names, and return them in an object.
Of course, asterisks etc. cannot be resolved, you should use allowed() to
check for a valid name.
'''
global blacklist
if blacklist is None:
# not yet loaded
path = os.path.join(os.path.dirname(__file... | [
"def",
"names",
"(",
")",
":",
"global",
"blacklist",
"if",
"blacklist",
"is",
"None",
":",
"# not yet loaded",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'names.yaml'",
")",
"f",
... | Lazy-load the tree of names, and return them in an object.
Of course, asterisks etc. cannot be resolved, you should use allowed() to
check for a valid name. | [
"Lazy",
"-",
"load",
"the",
"tree",
"of",
"names",
"and",
"return",
"them",
"in",
"an",
"object",
".",
"Of",
"course",
"asterisks",
"etc",
".",
"cannot",
"be",
"resolved",
"you",
"should",
"use",
"allowed",
"()",
"to",
"check",
"for",
"a",
"valid",
"na... | train | https://github.com/aykevl/reserved/blob/70bc7a8edc87554a31bff613ae8979484b0468a0/names.py#L11-L24 |
aykevl/reserved | names.py | valid | def valid(name, maxlength=None):
'''
Return the lowercase name if this name adheres to requirements, None
otherwise.
The requirements are:
* only alphanumeric characters or dashes
* no number at the start
* no double dashes or dashes at the start or end of the name
* no empty str... | python | def valid(name, maxlength=None):
'''
Return the lowercase name if this name adheres to requirements, None
otherwise.
The requirements are:
* only alphanumeric characters or dashes
* no number at the start
* no double dashes or dashes at the start or end of the name
* no empty str... | [
"def",
"valid",
"(",
"name",
",",
"maxlength",
"=",
"None",
")",
":",
"if",
"not",
"name",
":",
"return",
"None",
"if",
"maxlength",
"is",
"not",
"None",
"and",
"len",
"(",
"name",
")",
">",
"maxlength",
":",
"return",
"None",
"name",
"=",
"name",
... | Return the lowercase name if this name adheres to requirements, None
otherwise.
The requirements are:
* only alphanumeric characters or dashes
* no number at the start
* no double dashes or dashes at the start or end of the name
* no empty string
* no string bigger than maxlength | [
"Return",
"the",
"lowercase",
"name",
"if",
"this",
"name",
"adheres",
"to",
"requirements",
"None",
"otherwise",
".",
"The",
"requirements",
"are",
":",
"*",
"only",
"alphanumeric",
"characters",
"or",
"dashes",
"*",
"no",
"number",
"at",
"the",
"start",
"*... | train | https://github.com/aykevl/reserved/blob/70bc7a8edc87554a31bff613ae8979484b0468a0/names.py#L26-L51 |
aykevl/reserved | names.py | allowed | def allowed(name, collection='all'):
'''
Return true if this name is allowed (e.g. not in the forbidden list,
indicated by 'collection'), false otherwise.
'''
if not valid(name):
return False
blacklist = names()
for forbidden in blacklist[collection]:
if name.lower() == for... | python | def allowed(name, collection='all'):
'''
Return true if this name is allowed (e.g. not in the forbidden list,
indicated by 'collection'), false otherwise.
'''
if not valid(name):
return False
blacklist = names()
for forbidden in blacklist[collection]:
if name.lower() == for... | [
"def",
"allowed",
"(",
"name",
",",
"collection",
"=",
"'all'",
")",
":",
"if",
"not",
"valid",
"(",
"name",
")",
":",
"return",
"False",
"blacklist",
"=",
"names",
"(",
")",
"for",
"forbidden",
"in",
"blacklist",
"[",
"collection",
"]",
":",
"if",
"... | Return true if this name is allowed (e.g. not in the forbidden list,
indicated by 'collection'), false otherwise. | [
"Return",
"true",
"if",
"this",
"name",
"is",
"allowed",
"(",
"e",
".",
"g",
".",
"not",
"in",
"the",
"forbidden",
"list",
"indicated",
"by",
"collection",
")",
"false",
"otherwise",
"."
] | train | https://github.com/aykevl/reserved/blob/70bc7a8edc87554a31bff613ae8979484b0468a0/names.py#L53-L76 |
char16t/wa | wa/api.py | GeneratorAPI.copy_tree_and_replace_vars | def copy_tree_and_replace_vars(self, src, dst):
"""
Если передается директория в качестве аргумента, то будет
рассматриваться как шаблон именно её содержимое!! Оно же и будет
копироваться
"""
if os.path.isdir(src):
copy_tree(src, self.temp_dir)
elif os... | python | def copy_tree_and_replace_vars(self, src, dst):
"""
Если передается директория в качестве аргумента, то будет
рассматриваться как шаблон именно её содержимое!! Оно же и будет
копироваться
"""
if os.path.isdir(src):
copy_tree(src, self.temp_dir)
elif os... | [
"def",
"copy_tree_and_replace_vars",
"(",
"self",
",",
"src",
",",
"dst",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"src",
")",
":",
"copy_tree",
"(",
"src",
",",
"self",
".",
"temp_dir",
")",
"elif",
"os",
".",
"path",
".",
"isfile",
"... | Если передается директория в качестве аргумента, то будет
рассматриваться как шаблон именно её содержимое!! Оно же и будет
копироваться | [
"Если",
"передается",
"директория",
"в",
"качестве",
"аргумента",
"то",
"будет",
"рассматриваться",
"как",
"шаблон",
"именно",
"её",
"содержимое!!",
"Оно",
"же",
"и",
"будет",
"копироваться"
] | train | https://github.com/char16t/wa/blob/ee28bf47665ea57f3a03a08dfc0a5daaa33d8121/wa/api.py#L130-L150 |
char16t/wa | wa/api.py | GeneratorAPI.replace_f | def replace_f(self, path, arg_name=None):
"""Replace files"""
root, file = os.path.split(path)
pattern = re.compile(r'(\<\<\<)([A-Za-z_]+)(\>\>\>)')
file_path = path
fh, abs_path = mkstemp()
with open(abs_path, 'w') as new_file:
with open(file_path) as old_fi... | python | def replace_f(self, path, arg_name=None):
"""Replace files"""
root, file = os.path.split(path)
pattern = re.compile(r'(\<\<\<)([A-Za-z_]+)(\>\>\>)')
file_path = path
fh, abs_path = mkstemp()
with open(abs_path, 'w') as new_file:
with open(file_path) as old_fi... | [
"def",
"replace_f",
"(",
"self",
",",
"path",
",",
"arg_name",
"=",
"None",
")",
":",
"root",
",",
"file",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'(\\<\\<\\<)([A-Za-z_]+)(\\>\\>\\>)'",
")",
... | Replace files | [
"Replace",
"files"
] | train | https://github.com/char16t/wa/blob/ee28bf47665ea57f3a03a08dfc0a5daaa33d8121/wa/api.py#L152-L174 |
char16t/wa | wa/api.py | GeneratorAPI.replace_d | def replace_d(self, path, arg_name=None):
"""Replace directories
Но в некоторых местах проекта может быть
вызвана в тех местах, где нужно изменять
имена файлов не трогая содержание
"""
root, dir = os.path.split(path)
pattern = re.compile(r'(\[\[)([A-Za-z_]+)(\]\])... | python | def replace_d(self, path, arg_name=None):
"""Replace directories
Но в некоторых местах проекта может быть
вызвана в тех местах, где нужно изменять
имена файлов не трогая содержание
"""
root, dir = os.path.split(path)
pattern = re.compile(r'(\[\[)([A-Za-z_]+)(\]\])... | [
"def",
"replace_d",
"(",
"self",
",",
"path",
",",
"arg_name",
"=",
"None",
")",
":",
"root",
",",
"dir",
"=",
"os",
".",
"path",
".",
"split",
"(",
"path",
")",
"pattern",
"=",
"re",
".",
"compile",
"(",
"r'(\\[\\[)([A-Za-z_]+)(\\]\\])'",
")",
"for",
... | Replace directories
Но в некоторых местах проекта может быть
вызвана в тех местах, где нужно изменять
имена файлов не трогая содержание | [
"Replace",
"directories",
"Но",
"в",
"некоторых",
"местах",
"проекта",
"может",
"быть",
"вызвана",
"в",
"тех",
"местах",
"где",
"нужно",
"изменять",
"имена",
"файлов",
"не",
"трогая",
"содержание"
] | train | https://github.com/char16t/wa/blob/ee28bf47665ea57f3a03a08dfc0a5daaa33d8121/wa/api.py#L176-L186 |
kallimachos/chios | chios/remoteinclude/__init__.py | setup | def setup(app):
"""
Setup for Sphinx extension.
:param app: Sphinx application context.
"""
app.info('adding remote-include directive...', nonl=True)
app.add_directive('remote-include', RemoteInclude)
app.info(' done')
return {
'version': __version__,
'parallel_read_safe... | python | def setup(app):
"""
Setup for Sphinx extension.
:param app: Sphinx application context.
"""
app.info('adding remote-include directive...', nonl=True)
app.add_directive('remote-include', RemoteInclude)
app.info(' done')
return {
'version': __version__,
'parallel_read_safe... | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"info",
"(",
"'adding remote-include directive...'",
",",
"nonl",
"=",
"True",
")",
"app",
".",
"add_directive",
"(",
"'remote-include'",
",",
"RemoteInclude",
")",
"app",
".",
"info",
"(",
"' done'",
")",
... | Setup for Sphinx extension.
:param app: Sphinx application context. | [
"Setup",
"for",
"Sphinx",
"extension",
"."
] | train | https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remoteinclude/__init__.py#L60-L73 |
kallimachos/chios | chios/remoteinclude/__init__.py | RemoteInclude.run | def run(self):
"""Return rel path to a downloaded file as `include` node argument."""
document = self.state.document
env = document.settings.env
buildpath = env.app.outdir
link = self.arguments[0]
try:
r = requests.get(link)
r.raise_for_status()
... | python | def run(self):
"""Return rel path to a downloaded file as `include` node argument."""
document = self.state.document
env = document.settings.env
buildpath = env.app.outdir
link = self.arguments[0]
try:
r = requests.get(link)
r.raise_for_status()
... | [
"def",
"run",
"(",
"self",
")",
":",
"document",
"=",
"self",
".",
"state",
".",
"document",
"env",
"=",
"document",
".",
"settings",
".",
"env",
"buildpath",
"=",
"env",
".",
"app",
".",
"outdir",
"link",
"=",
"self",
".",
"arguments",
"[",
"0",
"... | Return rel path to a downloaded file as `include` node argument. | [
"Return",
"rel",
"path",
"to",
"a",
"downloaded",
"file",
"as",
"include",
"node",
"argument",
"."
] | train | https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remoteinclude/__init__.py#L35-L57 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer.deserialize | def deserialize(self):
""" Invoke the deserializer
The JsonDeserializer.deserializer() method will
return a dict of the JSON payload.
:return:
normalized dict
"""
body = super(Deserializer, self).deserialize()
self.parse(body)
return self.n... | python | def deserialize(self):
""" Invoke the deserializer
The JsonDeserializer.deserializer() method will
return a dict of the JSON payload.
:return:
normalized dict
"""
body = super(Deserializer, self).deserialize()
self.parse(body)
return self.n... | [
"def",
"deserialize",
"(",
"self",
")",
":",
"body",
"=",
"super",
"(",
"Deserializer",
",",
"self",
")",
".",
"deserialize",
"(",
")",
"self",
".",
"parse",
"(",
"body",
")",
"return",
"self",
".",
"normalize",
"(",
"body",
")"
] | Invoke the deserializer
The JsonDeserializer.deserializer() method will
return a dict of the JSON payload.
:return:
normalized dict | [
"Invoke",
"the",
"deserializer"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L33-L46 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer._normalize_relationships | def _normalize_relationships(relationships):
""" Get all the relationships by key/val & return them
A normalized relationship dict uses the key name without
any alteration but the value will be the `id` provided
in the payload if present. If not present, then the client
wants to... | python | def _normalize_relationships(relationships):
""" Get all the relationships by key/val & return them
A normalized relationship dict uses the key name without
any alteration but the value will be the `id` provided
in the payload if present. If not present, then the client
wants to... | [
"def",
"_normalize_relationships",
"(",
"relationships",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"relationships",
".",
"items",
"(",
")",
":",
"if",
"not",
"val",
"[",
"'data'",
"]",
":",
"ret",
"[",
"key",
"]",
"=",
"None",
... | Get all the relationships by key/val & return them
A normalized relationship dict uses the key name without
any alteration but the value will be the `id` provided
in the payload if present. If not present, then the client
wants to unset the relationship so it will be set to None.
... | [
"Get",
"all",
"the",
"relationships",
"by",
"key",
"/",
"val",
"&",
"return",
"them"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L60-L83 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer.normalize | def normalize(self, body):
""" Invoke the JSON API normalizer
Perform the following:
* add the type as a rtype property
* flatten the payload
* add the id as a rid property ONLY if present
We don't need to vet the inputs much because the Parser
has ... | python | def normalize(self, body):
""" Invoke the JSON API normalizer
Perform the following:
* add the type as a rtype property
* flatten the payload
* add the id as a rid property ONLY if present
We don't need to vet the inputs much because the Parser
has ... | [
"def",
"normalize",
"(",
"self",
",",
"body",
")",
":",
"resource",
"=",
"body",
"[",
"'data'",
"]",
"data",
"=",
"{",
"'rtype'",
":",
"resource",
"[",
"'type'",
"]",
"}",
"if",
"'attributes'",
"in",
"resource",
":",
"attributes",
"=",
"resource",
"[",... | Invoke the JSON API normalizer
Perform the following:
* add the type as a rtype property
* flatten the payload
* add the id as a rid property ONLY if present
We don't need to vet the inputs much because the Parser
has already done all the work.
:pa... | [
"Invoke",
"the",
"JSON",
"API",
"normalizer"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L85-L121 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer._parse_attributes | def _parse_attributes(self, attributes):
""" Ensure compliance with the spec's attributes section
Specifically, the attributes object of the single resource
object. This contains the key / values to be mapped to the
model.
:param attributes:
dict JSON API attributes... | python | def _parse_attributes(self, attributes):
""" Ensure compliance with the spec's attributes section
Specifically, the attributes object of the single resource
object. This contains the key / values to be mapped to the
model.
:param attributes:
dict JSON API attributes... | [
"def",
"_parse_attributes",
"(",
"self",
",",
"attributes",
")",
":",
"link",
"=",
"'jsonapi.org/format/#document-resource-object-attributes'",
"if",
"not",
"isinstance",
"(",
"attributes",
",",
"dict",
")",
":",
"self",
".",
"fail",
"(",
"'The JSON API resource objec... | Ensure compliance with the spec's attributes section
Specifically, the attributes object of the single resource
object. This contains the key / values to be mapped to the
model.
:param attributes:
dict JSON API attributes object | [
"Ensure",
"compliance",
"with",
"the",
"spec",
"s",
"attributes",
"section"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L123-L142 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer._parse_relationships | def _parse_relationships(self, relationships):
""" Ensure compliance with the spec's relationships section
Specifically, the relationships object of the single resource
object. For modifications we only support relationships via
the `data` key referred to as Resource Linkage.
:... | python | def _parse_relationships(self, relationships):
""" Ensure compliance with the spec's relationships section
Specifically, the relationships object of the single resource
object. For modifications we only support relationships via
the `data` key referred to as Resource Linkage.
:... | [
"def",
"_parse_relationships",
"(",
"self",
",",
"relationships",
")",
":",
"link",
"=",
"'jsonapi.org/format/#document-resource-object-relationships'",
"if",
"not",
"isinstance",
"(",
"relationships",
",",
"dict",
")",
":",
"self",
".",
"fail",
"(",
"'The JSON API re... | Ensure compliance with the spec's relationships section
Specifically, the relationships object of the single resource
object. For modifications we only support relationships via
the `data` key referred to as Resource Linkage.
:param relationships:
dict JSON API relationship... | [
"Ensure",
"compliance",
"with",
"the",
"spec",
"s",
"relationships",
"section"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L144-L189 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer._parse_resource | def _parse_resource(self, resource):
""" Ensure compliance with the spec's resource objects section
:param resource:
dict JSON API resource object
"""
link = 'jsonapi.org/format/#document-resource-objects'
rid = isinstance(resource.get('id'), unicode)
rtype ... | python | def _parse_resource(self, resource):
""" Ensure compliance with the spec's resource objects section
:param resource:
dict JSON API resource object
"""
link = 'jsonapi.org/format/#document-resource-objects'
rid = isinstance(resource.get('id'), unicode)
rtype ... | [
"def",
"_parse_resource",
"(",
"self",
",",
"resource",
")",
":",
"link",
"=",
"'jsonapi.org/format/#document-resource-objects'",
"rid",
"=",
"isinstance",
"(",
"resource",
".",
"get",
"(",
"'id'",
")",
",",
"unicode",
")",
"rtype",
"=",
"isinstance",
"(",
"re... | Ensure compliance with the spec's resource objects section
:param resource:
dict JSON API resource object | [
"Ensure",
"compliance",
"with",
"the",
"spec",
"s",
"resource",
"objects",
"section"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L191-L219 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer._parse_top_level | def _parse_top_level(self, body):
""" Ensure compliance with the spec's top-level section """
link = 'jsonapi.org/format/#document-top-level'
try:
if not isinstance(body['data'], dict):
raise TypeError
except (KeyError, TypeError):
self.fail('JSO... | python | def _parse_top_level(self, body):
""" Ensure compliance with the spec's top-level section """
link = 'jsonapi.org/format/#document-top-level'
try:
if not isinstance(body['data'], dict):
raise TypeError
except (KeyError, TypeError):
self.fail('JSO... | [
"def",
"_parse_top_level",
"(",
"self",
",",
"body",
")",
":",
"link",
"=",
"'jsonapi.org/format/#document-top-level'",
"try",
":",
"if",
"not",
"isinstance",
"(",
"body",
"[",
"'data'",
"]",
",",
"dict",
")",
":",
"raise",
"TypeError",
"except",
"(",
"KeyEr... | Ensure compliance with the spec's top-level section | [
"Ensure",
"compliance",
"with",
"the",
"spec",
"s",
"top",
"-",
"level",
"section"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L221-L238 |
sassoo/goldman | goldman/deserializers/jsonapi.py | Deserializer.parse | def parse(self, body):
""" Invoke the JSON API spec compliant parser
Order is important. Start from the request body root key
& work your way down so exception handling is easier to
follow.
:return:
the parsed & vetted request body
"""
self._parse_t... | python | def parse(self, body):
""" Invoke the JSON API spec compliant parser
Order is important. Start from the request body root key
& work your way down so exception handling is easier to
follow.
:return:
the parsed & vetted request body
"""
self._parse_t... | [
"def",
"parse",
"(",
"self",
",",
"body",
")",
":",
"self",
".",
"_parse_top_level",
"(",
"body",
")",
"self",
".",
"_parse_resource",
"(",
"body",
"[",
"'data'",
"]",
")",
"resource",
"=",
"body",
"[",
"'data'",
"]",
"if",
"'attributes'",
"in",
"resou... | Invoke the JSON API spec compliant parser
Order is important. Start from the request body root key
& work your way down so exception handling is easier to
follow.
:return:
the parsed & vetted request body | [
"Invoke",
"the",
"JSON",
"API",
"spec",
"compliant",
"parser"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/deserializers/jsonapi.py#L240-L259 |
baliame/http-hmac-python | httphmac/compat.py | get_signer_by_version | def get_signer_by_version(digest, ver):
"""Returns a new signer object for a digest and version combination.
Keyword arguments:
digest -- a callable that may be passed to the initializer of any Signer object in this library.
The callable must return a hasher object when called with no arguments.
... | python | def get_signer_by_version(digest, ver):
"""Returns a new signer object for a digest and version combination.
Keyword arguments:
digest -- a callable that may be passed to the initializer of any Signer object in this library.
The callable must return a hasher object when called with no arguments.
... | [
"def",
"get_signer_by_version",
"(",
"digest",
",",
"ver",
")",
":",
"if",
"int",
"(",
"ver",
")",
"==",
"1",
":",
"return",
"V1Signer",
"(",
"digest",
")",
"elif",
"int",
"(",
"ver",
")",
"==",
"2",
":",
"return",
"V2Signer",
"(",
"digest",
")",
"... | Returns a new signer object for a digest and version combination.
Keyword arguments:
digest -- a callable that may be passed to the initializer of any Signer object in this library.
The callable must return a hasher object when called with no arguments.
ver -- the version of the signature. This may... | [
"Returns",
"a",
"new",
"signer",
"object",
"for",
"a",
"digest",
"and",
"version",
"combination",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/compat.py#L6-L19 |
baliame/http-hmac-python | httphmac/compat.py | SignatureIdentifier.identify | def identify(self, header):
"""Identifies a signature and returns the appropriate Signer object.
This is done by reading an authorization header and matching it to signature characteristics.
None is returned if the authorization header does not match the format of any signature identified by thi... | python | def identify(self, header):
"""Identifies a signature and returns the appropriate Signer object.
This is done by reading an authorization header and matching it to signature characteristics.
None is returned if the authorization header does not match the format of any signature identified by thi... | [
"def",
"identify",
"(",
"self",
",",
"header",
")",
":",
"for",
"ver",
",",
"signer",
"in",
"self",
".",
"signers",
".",
"items",
"(",
")",
":",
"if",
"signer",
".",
"matches",
"(",
"header",
")",
":",
"return",
"signer",
"return",
"None"
] | Identifies a signature and returns the appropriate Signer object.
This is done by reading an authorization header and matching it to signature characteristics.
None is returned if the authorization header does not match the format of any signature identified by this identifier.
Keyword argument... | [
"Identifies",
"a",
"signature",
"and",
"returns",
"the",
"appropriate",
"Signer",
"object",
".",
"This",
"is",
"done",
"by",
"reading",
"an",
"authorization",
"header",
"and",
"matching",
"it",
"to",
"signature",
"characteristics",
".",
"None",
"is",
"returned",... | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/compat.py#L41-L52 |
keik/audiotrans | audiotrans/load_transforms.py | load_transforms | def load_transforms(transforms):
"""
Load transform modules and return instance of transform class.
Parameters
----------
transforms : [str] or [[str]]
array of transform module name,
or nested array of transform module name with argv to load
Returns
-------
array o... | python | def load_transforms(transforms):
"""
Load transform modules and return instance of transform class.
Parameters
----------
transforms : [str] or [[str]]
array of transform module name,
or nested array of transform module name with argv to load
Returns
-------
array o... | [
"def",
"load_transforms",
"(",
"transforms",
")",
":",
"from",
".",
"import",
"Transform",
"import",
"inspect",
"# normalize arguments to form as [(name, [option, ...]), ...]",
"transforms_with_argv",
"=",
"map",
"(",
"lambda",
"t",
":",
"(",
"t",
"[",
"0",
"]",
","... | Load transform modules and return instance of transform class.
Parameters
----------
transforms : [str] or [[str]]
array of transform module name,
or nested array of transform module name with argv to load
Returns
-------
array of transform instance | [
"Load",
"transform",
"modules",
"and",
"return",
"instance",
"of",
"transform",
"class",
"."
] | train | https://github.com/keik/audiotrans/blob/0849e32b9eacc3256a9da48d1cab8935448fa1e7/audiotrans/load_transforms.py#L4-L42 |
fakedrake/overlay_parse | overlay_parse/dates.py | date_tuple | def date_tuple(ovls):
"""
We should have a list of overlays from which to extract day month
year.
"""
day = month = year = 0
for o in ovls:
if 'day' in o.props:
day = o.value
if 'month' in o.props:
month = o.value
if 'year' in o.props:
... | python | def date_tuple(ovls):
"""
We should have a list of overlays from which to extract day month
year.
"""
day = month = year = 0
for o in ovls:
if 'day' in o.props:
day = o.value
if 'month' in o.props:
month = o.value
if 'year' in o.props:
... | [
"def",
"date_tuple",
"(",
"ovls",
")",
":",
"day",
"=",
"month",
"=",
"year",
"=",
"0",
"for",
"o",
"in",
"ovls",
":",
"if",
"'day'",
"in",
"o",
".",
"props",
":",
"day",
"=",
"o",
".",
"value",
"if",
"'month'",
"in",
"o",
".",
"props",
":",
... | We should have a list of overlays from which to extract day month
year. | [
"We",
"should",
"have",
"a",
"list",
"of",
"overlays",
"from",
"which",
"to",
"extract",
"day",
"month",
"year",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/dates.py#L57-L78 |
fakedrake/overlay_parse | overlay_parse/dates.py | longest_overlap | def longest_overlap(ovls):
"""
From a list of overlays if any overlap keep the longest.
"""
# Ovls know how to compare to each other.
ovls = sorted(ovls)
# I know this could be better but ovls wont be more than 50 or so.
for i, s in enumerate(ovls):
passing = True
for l in... | python | def longest_overlap(ovls):
"""
From a list of overlays if any overlap keep the longest.
"""
# Ovls know how to compare to each other.
ovls = sorted(ovls)
# I know this could be better but ovls wont be more than 50 or so.
for i, s in enumerate(ovls):
passing = True
for l in... | [
"def",
"longest_overlap",
"(",
"ovls",
")",
":",
"# Ovls know how to compare to each other.",
"ovls",
"=",
"sorted",
"(",
"ovls",
")",
"# I know this could be better but ovls wont be more than 50 or so.",
"for",
"i",
",",
"s",
"in",
"enumerate",
"(",
"ovls",
")",
":",
... | From a list of overlays if any overlap keep the longest. | [
"From",
"a",
"list",
"of",
"overlays",
"if",
"any",
"overlap",
"keep",
"the",
"longest",
"."
] | train | https://github.com/fakedrake/overlay_parse/blob/9ac362d6aef1ea41aff7375af088c6ebef93d0cd/overlay_parse/dates.py#L81-L100 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | GetSchema | def GetSchema(component):
"""convience function for finding the parent XMLSchema instance.
"""
parent = component
while not isinstance(parent, XMLSchema):
parent = parent._parent()
return parent | python | def GetSchema(component):
"""convience function for finding the parent XMLSchema instance.
"""
parent = component
while not isinstance(parent, XMLSchema):
parent = parent._parent()
return parent | [
"def",
"GetSchema",
"(",
"component",
")",
":",
"parent",
"=",
"component",
"while",
"not",
"isinstance",
"(",
"parent",
",",
"XMLSchema",
")",
":",
"parent",
"=",
"parent",
".",
"_parent",
"(",
")",
"return",
"parent"
] | convience function for finding the parent XMLSchema instance. | [
"convience",
"function",
"for",
"finding",
"the",
"parent",
"XMLSchema",
"instance",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L42-L48 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.__setImports | def __setImports(self, schema):
"""Add dictionary of imports to schema instance.
schema -- XMLSchema instance
"""
for ns,val in schema.imports.items():
if self._imports.has_key(ns):
schema.addImportSchema(self._imports[ns]) | python | def __setImports(self, schema):
"""Add dictionary of imports to schema instance.
schema -- XMLSchema instance
"""
for ns,val in schema.imports.items():
if self._imports.has_key(ns):
schema.addImportSchema(self._imports[ns]) | [
"def",
"__setImports",
"(",
"self",
",",
"schema",
")",
":",
"for",
"ns",
",",
"val",
"in",
"schema",
".",
"imports",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_imports",
".",
"has_key",
"(",
"ns",
")",
":",
"schema",
".",
"addImportSchema",
... | Add dictionary of imports to schema instance.
schema -- XMLSchema instance | [
"Add",
"dictionary",
"of",
"imports",
"to",
"schema",
"instance",
".",
"schema",
"--",
"XMLSchema",
"instance"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L67-L73 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.__setIncludes | def __setIncludes(self, schema):
"""Add dictionary of includes to schema instance.
schema -- XMLSchema instance
"""
for schemaLocation, val in schema.includes.items():
if self._includes.has_key(schemaLocation):
schema.addIncludeSchema(schemaLocation, self.... | python | def __setIncludes(self, schema):
"""Add dictionary of includes to schema instance.
schema -- XMLSchema instance
"""
for schemaLocation, val in schema.includes.items():
if self._includes.has_key(schemaLocation):
schema.addIncludeSchema(schemaLocation, self.... | [
"def",
"__setIncludes",
"(",
"self",
",",
"schema",
")",
":",
"for",
"schemaLocation",
",",
"val",
"in",
"schema",
".",
"includes",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_includes",
".",
"has_key",
"(",
"schemaLocation",
")",
":",
"schema",
... | Add dictionary of includes to schema instance.
schema -- XMLSchema instance | [
"Add",
"dictionary",
"of",
"includes",
"to",
"schema",
"instance",
".",
"schema",
"--",
"XMLSchema",
"instance"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L75-L81 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.loadFromNode | def loadFromNode(self, parent, element):
"""element -- DOM node or document
parent -- WSDLAdapter instance
"""
reader = self.__readerClass(element)
schema = XMLSchema(parent)
#HACK to keep a reference
schema.wsdl = parent
schema.setBaseUrl(self.__base_u... | python | def loadFromNode(self, parent, element):
"""element -- DOM node or document
parent -- WSDLAdapter instance
"""
reader = self.__readerClass(element)
schema = XMLSchema(parent)
#HACK to keep a reference
schema.wsdl = parent
schema.setBaseUrl(self.__base_u... | [
"def",
"loadFromNode",
"(",
"self",
",",
"parent",
",",
"element",
")",
":",
"reader",
"=",
"self",
".",
"__readerClass",
"(",
"element",
")",
"schema",
"=",
"XMLSchema",
"(",
"parent",
")",
"#HACK to keep a reference",
"schema",
".",
"wsdl",
"=",
"parent",
... | element -- DOM node or document
parent -- WSDLAdapter instance | [
"element",
"--",
"DOM",
"node",
"or",
"document",
"parent",
"--",
"WSDLAdapter",
"instance"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L93-L103 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.loadFromStream | def loadFromStream(self, file, url=None):
"""Return an XMLSchema instance loaded from a file object.
file -- file object
url -- base location for resolving imports/includes.
"""
reader = self.__readerClass()
reader.loadDocument(file)
schema = XMLSchema()
... | python | def loadFromStream(self, file, url=None):
"""Return an XMLSchema instance loaded from a file object.
file -- file object
url -- base location for resolving imports/includes.
"""
reader = self.__readerClass()
reader.loadDocument(file)
schema = XMLSchema()
... | [
"def",
"loadFromStream",
"(",
"self",
",",
"file",
",",
"url",
"=",
"None",
")",
":",
"reader",
"=",
"self",
".",
"__readerClass",
"(",
")",
"reader",
".",
"loadDocument",
"(",
"file",
")",
"schema",
"=",
"XMLSchema",
"(",
")",
"if",
"url",
"is",
"no... | Return an XMLSchema instance loaded from a file object.
file -- file object
url -- base location for resolving imports/includes. | [
"Return",
"an",
"XMLSchema",
"instance",
"loaded",
"from",
"a",
"file",
"object",
".",
"file",
"--",
"file",
"object",
"url",
"--",
"base",
"location",
"for",
"resolving",
"imports",
"/",
"includes",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L105-L118 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.loadFromURL | def loadFromURL(self, url, schema=None):
"""Return an XMLSchema instance loaded from the given url.
url -- URL to dereference
schema -- Optional XMLSchema instance.
"""
reader = self.__readerClass()
if self.__base_url:
url = basejoin(self.__base_url,url)... | python | def loadFromURL(self, url, schema=None):
"""Return an XMLSchema instance loaded from the given url.
url -- URL to dereference
schema -- Optional XMLSchema instance.
"""
reader = self.__readerClass()
if self.__base_url:
url = basejoin(self.__base_url,url)... | [
"def",
"loadFromURL",
"(",
"self",
",",
"url",
",",
"schema",
"=",
"None",
")",
":",
"reader",
"=",
"self",
".",
"__readerClass",
"(",
")",
"if",
"self",
".",
"__base_url",
":",
"url",
"=",
"basejoin",
"(",
"self",
".",
"__base_url",
",",
"url",
")",... | Return an XMLSchema instance loaded from the given url.
url -- URL to dereference
schema -- Optional XMLSchema instance. | [
"Return",
"an",
"XMLSchema",
"instance",
"loaded",
"from",
"the",
"given",
"url",
".",
"url",
"--",
"URL",
"to",
"dereference",
"schema",
"--",
"Optional",
"XMLSchema",
"instance",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L126-L141 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | SchemaReader.loadFromFile | def loadFromFile(self, filename):
"""Return an XMLSchema instance loaded from the given file.
filename -- name of file to open
"""
if self.__base_url:
filename = basejoin(self.__base_url,filename)
file = open(filename, 'rb')
try:
schema = self.l... | python | def loadFromFile(self, filename):
"""Return an XMLSchema instance loaded from the given file.
filename -- name of file to open
"""
if self.__base_url:
filename = basejoin(self.__base_url,filename)
file = open(filename, 'rb')
try:
schema = self.l... | [
"def",
"loadFromFile",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"__base_url",
":",
"filename",
"=",
"basejoin",
"(",
"self",
".",
"__base_url",
",",
"filename",
")",
"file",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"try",
":",
... | Return an XMLSchema instance loaded from the given file.
filename -- name of file to open | [
"Return",
"an",
"XMLSchema",
"instance",
"loaded",
"from",
"the",
"given",
"file",
".",
"filename",
"--",
"name",
"of",
"file",
"to",
"open"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L143-L155 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | DOMAdapter.hasattr | def hasattr(self, attr, ns=None):
"""attr -- attribute
ns -- optional namespace, None means unprefixed attribute.
"""
if not self.__attributes:
self.setAttributeDictionary()
if ns:
return self.__attributes.get(ns,{}).has_key(attr)
return self._... | python | def hasattr(self, attr, ns=None):
"""attr -- attribute
ns -- optional namespace, None means unprefixed attribute.
"""
if not self.__attributes:
self.setAttributeDictionary()
if ns:
return self.__attributes.get(ns,{}).has_key(attr)
return self._... | [
"def",
"hasattr",
"(",
"self",
",",
"attr",
",",
"ns",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"__attributes",
":",
"self",
".",
"setAttributeDictionary",
"(",
")",
"if",
"ns",
":",
"return",
"self",
".",
"__attributes",
".",
"get",
"(",
"ns... | attr -- attribute
ns -- optional namespace, None means unprefixed attribute. | [
"attr",
"--",
"attribute",
"ns",
"--",
"optional",
"namespace",
"None",
"means",
"unprefixed",
"attribute",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L237-L245 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | DOMAdapter.getNamespace | def getNamespace(self, prefix):
"""prefix -- deference namespace prefix in node's context.
Ascends parent nodes until found.
"""
namespace = None
if prefix == 'xmlns':
namespace = DOM.findDefaultNS(prefix, self.__node)
else:
try:
... | python | def getNamespace(self, prefix):
"""prefix -- deference namespace prefix in node's context.
Ascends parent nodes until found.
"""
namespace = None
if prefix == 'xmlns':
namespace = DOM.findDefaultNS(prefix, self.__node)
else:
try:
... | [
"def",
"getNamespace",
"(",
"self",
",",
"prefix",
")",
":",
"namespace",
"=",
"None",
"if",
"prefix",
"==",
"'xmlns'",
":",
"namespace",
"=",
"DOM",
".",
"findDefaultNS",
"(",
"prefix",
",",
"self",
".",
"__node",
")",
"else",
":",
"try",
":",
"namesp... | prefix -- deference namespace prefix in node's context.
Ascends parent nodes until found. | [
"prefix",
"--",
"deference",
"namespace",
"prefix",
"in",
"node",
"s",
"context",
".",
"Ascends",
"parent",
"nodes",
"until",
"found",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L274-L289 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getItemTrace | def getItemTrace(self):
"""Returns a node trace up to the <schema> item.
"""
item, path, name, ref = self, [], 'name', 'ref'
while not isinstance(item,XMLSchema) and not isinstance(item,WSDLToolsAdapter):
attr = item.getAttribute(name)
if not attr:
... | python | def getItemTrace(self):
"""Returns a node trace up to the <schema> item.
"""
item, path, name, ref = self, [], 'name', 'ref'
while not isinstance(item,XMLSchema) and not isinstance(item,WSDLToolsAdapter):
attr = item.getAttribute(name)
if not attr:
... | [
"def",
"getItemTrace",
"(",
"self",
")",
":",
"item",
",",
"path",
",",
"name",
",",
"ref",
"=",
"self",
",",
"[",
"]",
",",
"'name'",
",",
"'ref'",
"while",
"not",
"isinstance",
"(",
"item",
",",
"XMLSchema",
")",
"and",
"not",
"isinstance",
"(",
... | Returns a node trace up to the <schema> item. | [
"Returns",
"a",
"node",
"trace",
"up",
"to",
"the",
"<schema",
">",
"item",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L512-L534 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getTargetNamespace | def getTargetNamespace(self):
"""return targetNamespace
"""
parent = self
targetNamespace = 'targetNamespace'
tns = self.attributes.get(targetNamespace)
while not tns and parent and parent._parent is not None:
parent = parent._parent()
tns = parent... | python | def getTargetNamespace(self):
"""return targetNamespace
"""
parent = self
targetNamespace = 'targetNamespace'
tns = self.attributes.get(targetNamespace)
while not tns and parent and parent._parent is not None:
parent = parent._parent()
tns = parent... | [
"def",
"getTargetNamespace",
"(",
"self",
")",
":",
"parent",
"=",
"self",
"targetNamespace",
"=",
"'targetNamespace'",
"tns",
"=",
"self",
".",
"attributes",
".",
"get",
"(",
"targetNamespace",
")",
"while",
"not",
"tns",
"and",
"parent",
"and",
"parent",
"... | return targetNamespace | [
"return",
"targetNamespace"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L536-L545 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getQNameAttribute | def getQNameAttribute(self, collection, attribute):
"""returns object instance representing QName --> (namespace,name),
or if does not exist return None.
attribute -- an information item attribute, with a QName value.
collection -- collection in parent Schema instance to search.... | python | def getQNameAttribute(self, collection, attribute):
"""returns object instance representing QName --> (namespace,name),
or if does not exist return None.
attribute -- an information item attribute, with a QName value.
collection -- collection in parent Schema instance to search.... | [
"def",
"getQNameAttribute",
"(",
"self",
",",
"collection",
",",
"attribute",
")",
":",
"tdc",
"=",
"self",
".",
"getAttributeQName",
"(",
"attribute",
")",
"if",
"not",
"tdc",
":",
"return",
"obj",
"=",
"self",
".",
"getSchemaItem",
"(",
"collection",
","... | returns object instance representing QName --> (namespace,name),
or if does not exist return None.
attribute -- an information item attribute, with a QName value.
collection -- collection in parent Schema instance to search. | [
"returns",
"object",
"instance",
"representing",
"QName",
"--",
">",
"(",
"namespace",
"name",
")",
"or",
"if",
"does",
"not",
"exist",
"return",
"None",
".",
"attribute",
"--",
"an",
"information",
"item",
"attribute",
"with",
"a",
"QName",
"value",
".",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L577-L592 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getSchemaItem | def getSchemaItem(self, collection, namespace, name):
"""returns object instance representing namespace, name,
or if does not exist return None if built-in, else
raise SchemaError.
namespace -- namespace item defined in.
name -- name of item.
co... | python | def getSchemaItem(self, collection, namespace, name):
"""returns object instance representing namespace, name,
or if does not exist return None if built-in, else
raise SchemaError.
namespace -- namespace item defined in.
name -- name of item.
co... | [
"def",
"getSchemaItem",
"(",
"self",
",",
"collection",
",",
"namespace",
",",
"name",
")",
":",
"parent",
"=",
"GetSchema",
"(",
"self",
")",
"if",
"parent",
".",
"targetNamespace",
"==",
"namespace",
":",
"try",
":",
"obj",
"=",
"getattr",
"(",
"parent... | returns object instance representing namespace, name,
or if does not exist return None if built-in, else
raise SchemaError.
namespace -- namespace item defined in.
name -- name of item.
collection -- collection in parent Schema instance to search. | [
"returns",
"object",
"instance",
"representing",
"namespace",
"name",
"or",
"if",
"does",
"not",
"exist",
"return",
"None",
"if",
"built",
"-",
"in",
"else",
"raise",
"SchemaError",
".",
"namespace",
"--",
"namespace",
"item",
"defined",
"in",
".",
"name",
"... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L594-L646 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getXMLNS | def getXMLNS(self, prefix=None):
"""deference prefix or by default xmlns, returns namespace.
"""
if prefix == XMLSchemaComponent.xml:
return XMLNS.XML
parent = self
ns = self.attributes[XMLSchemaComponent.xmlns].get(prefix or\
XMLSchemaComponent.xmlns... | python | def getXMLNS(self, prefix=None):
"""deference prefix or by default xmlns, returns namespace.
"""
if prefix == XMLSchemaComponent.xml:
return XMLNS.XML
parent = self
ns = self.attributes[XMLSchemaComponent.xmlns].get(prefix or\
XMLSchemaComponent.xmlns... | [
"def",
"getXMLNS",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"if",
"prefix",
"==",
"XMLSchemaComponent",
".",
"xml",
":",
"return",
"XMLNS",
".",
"XML",
"parent",
"=",
"self",
"ns",
"=",
"self",
".",
"attributes",
"[",
"XMLSchemaComponent",
".",... | deference prefix or by default xmlns, returns namespace. | [
"deference",
"prefix",
"or",
"by",
"default",
"xmlns",
"returns",
"namespace",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L648-L664 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getAttribute | def getAttribute(self, attribute):
"""return requested attribute value or None
"""
if type(attribute) in (list, tuple):
if len(attribute) != 2:
raise LookupError, 'To access attributes must use name or (namespace,name)'
ns_dict = self.attributes.get(attri... | python | def getAttribute(self, attribute):
"""return requested attribute value or None
"""
if type(attribute) in (list, tuple):
if len(attribute) != 2:
raise LookupError, 'To access attributes must use name or (namespace,name)'
ns_dict = self.attributes.get(attri... | [
"def",
"getAttribute",
"(",
"self",
",",
"attribute",
")",
":",
"if",
"type",
"(",
"attribute",
")",
"in",
"(",
"list",
",",
"tuple",
")",
":",
"if",
"len",
"(",
"attribute",
")",
"!=",
"2",
":",
"raise",
"LookupError",
",",
"'To access attributes must u... | return requested attribute value or None | [
"return",
"requested",
"attribute",
"value",
"or",
"None"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L666-L679 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.getAttributeQName | def getAttributeQName(self, attribute):
"""return requested attribute value as (namespace,name) or None
"""
qname = self.getAttribute(attribute)
if isinstance(qname, TypeDescriptionComponent) is True:
return qname
if qname is None:
return None
pr... | python | def getAttributeQName(self, attribute):
"""return requested attribute value as (namespace,name) or None
"""
qname = self.getAttribute(attribute)
if isinstance(qname, TypeDescriptionComponent) is True:
return qname
if qname is None:
return None
pr... | [
"def",
"getAttributeQName",
"(",
"self",
",",
"attribute",
")",
":",
"qname",
"=",
"self",
".",
"getAttribute",
"(",
"attribute",
")",
"if",
"isinstance",
"(",
"qname",
",",
"TypeDescriptionComponent",
")",
"is",
"True",
":",
"return",
"qname",
"if",
"qname"... | return requested attribute value as (namespace,name) or None | [
"return",
"requested",
"attribute",
"value",
"as",
"(",
"namespace",
"name",
")",
"or",
"None"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L681-L692 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.setAttributes | def setAttributes(self, node):
"""Sets up attribute dictionary, checks for required attributes and
sets default attribute values. attr is for default attribute values
determined at runtime.
structure of attributes dictionary
['xmlns'][xmlns_key] -- ... | python | def setAttributes(self, node):
"""Sets up attribute dictionary, checks for required attributes and
sets default attribute values. attr is for default attribute values
determined at runtime.
structure of attributes dictionary
['xmlns'][xmlns_key] -- ... | [
"def",
"setAttributes",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"attributes",
"=",
"{",
"XMLSchemaComponent",
".",
"xmlns",
":",
"{",
"}",
"}",
"for",
"k",
",",
"v",
"in",
"node",
".",
"getAttributeDictionary",
"(",
")",
".",
"items",
"(",
"... | Sets up attribute dictionary, checks for required attributes and
sets default attribute values. attr is for default attribute values
determined at runtime.
structure of attributes dictionary
['xmlns'][xmlns_key] -- xmlns namespace
['xmlns'][p... | [
"Sets",
"up",
"attribute",
"dictionary",
"checks",
"for",
"required",
"attributes",
"and",
"sets",
"default",
"attribute",
"values",
".",
"attr",
"is",
"for",
"default",
"attribute",
"values",
"determined",
"at",
"runtime",
".",
"structure",
"of",
"attributes",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L699-L753 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.__setAttributeDefaults | def __setAttributeDefaults(self):
"""Looks for default values for unset attributes. If
class variable representing attribute is None, then
it must be defined as an instance variable.
"""
for k,v in self.__class__.attributes.items():
if v is not None and self.at... | python | def __setAttributeDefaults(self):
"""Looks for default values for unset attributes. If
class variable representing attribute is None, then
it must be defined as an instance variable.
"""
for k,v in self.__class__.attributes.items():
if v is not None and self.at... | [
"def",
"__setAttributeDefaults",
"(",
"self",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__class__",
".",
"attributes",
".",
"items",
"(",
")",
":",
"if",
"v",
"is",
"not",
"None",
"and",
"self",
".",
"attributes",
".",
"has_key",
"(",
"k",
... | Looks for default values for unset attributes. If
class variable representing attribute is None, then
it must be defined as an instance variable. | [
"Looks",
"for",
"default",
"values",
"for",
"unset",
"attributes",
".",
"If",
"class",
"variable",
"representing",
"attribute",
"is",
"None",
"then",
"it",
"must",
"be",
"defined",
"as",
"an",
"instance",
"variable",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L760-L770 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchemaComponent.__checkAttributes | def __checkAttributes(self):
"""Checks that required attributes have been defined,
attributes w/default cannot be required. Checks
all defined attributes are legal, attribute
references are not subject to this test.
"""
for a in self.__class__.required:
... | python | def __checkAttributes(self):
"""Checks that required attributes have been defined,
attributes w/default cannot be required. Checks
all defined attributes are legal, attribute
references are not subject to this test.
"""
for a in self.__class__.required:
... | [
"def",
"__checkAttributes",
"(",
"self",
")",
":",
"for",
"a",
"in",
"self",
".",
"__class__",
".",
"required",
":",
"if",
"not",
"self",
".",
"attributes",
".",
"has_key",
"(",
"a",
")",
":",
"raise",
"SchemaError",
",",
"'class instance %s, missing require... | Checks that required attributes have been defined,
attributes w/default cannot be required. Checks
all defined attributes are legal, attribute
references are not subject to this test. | [
"Checks",
"that",
"required",
"attributes",
"have",
"been",
"defined",
"attributes",
"w",
"/",
"default",
"cannot",
"be",
"required",
".",
"Checks",
"all",
"defined",
"attributes",
"are",
"legal",
"attribute",
"references",
"are",
"not",
"subject",
"to",
"this",... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L772-L795 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchema.addImportSchema | def addImportSchema(self, schema):
"""for resolving import statements in Schema instance
schema -- schema instance
_imported_schemas
"""
if not isinstance(schema, XMLSchema):
raise TypeError, 'expecting a Schema instance'
if schema.targetNamespace != se... | python | def addImportSchema(self, schema):
"""for resolving import statements in Schema instance
schema -- schema instance
_imported_schemas
"""
if not isinstance(schema, XMLSchema):
raise TypeError, 'expecting a Schema instance'
if schema.targetNamespace != se... | [
"def",
"addImportSchema",
"(",
"self",
",",
"schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"XMLSchema",
")",
":",
"raise",
"TypeError",
",",
"'expecting a Schema instance'",
"if",
"schema",
".",
"targetNamespace",
"!=",
"self",
".",
"target... | for resolving import statements in Schema instance
schema -- schema instance
_imported_schemas | [
"for",
"resolving",
"import",
"statements",
"in",
"Schema",
"instance",
"schema",
"--",
"schema",
"instance",
"_imported_schemas"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L1061-L1071 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | XMLSchema.addIncludeSchema | def addIncludeSchema(self, schemaLocation, schema):
"""for resolving include statements in Schema instance
schemaLocation -- schema location
schema -- schema instance
_included_schemas
"""
if not isinstance(schema, XMLSchema):
raise TypeError, 'expec... | python | def addIncludeSchema(self, schemaLocation, schema):
"""for resolving include statements in Schema instance
schemaLocation -- schema location
schema -- schema instance
_included_schemas
"""
if not isinstance(schema, XMLSchema):
raise TypeError, 'expec... | [
"def",
"addIncludeSchema",
"(",
"self",
",",
"schemaLocation",
",",
"schema",
")",
":",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"XMLSchema",
")",
":",
"raise",
"TypeError",
",",
"'expecting a Schema instance'",
"if",
"not",
"schema",
".",
"targetNamespace... | for resolving include statements in Schema instance
schemaLocation -- schema location
schema -- schema instance
_included_schemas | [
"for",
"resolving",
"include",
"statements",
"in",
"Schema",
"instance",
"schemaLocation",
"--",
"schema",
"location",
"schema",
"--",
"schema",
"instance",
"_included_schemas"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L1073-L1085 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | ElementDeclaration.getAttribute | def getAttribute(self, attribute):
"""return attribute.
If attribute is type and it's None, and no simple or complex content,
return the default type "xsd:anyType"
"""
value = XMLSchemaComponent.getAttribute(self, attribute)
if attribute != 'type' or value is not None:
... | python | def getAttribute(self, attribute):
"""return attribute.
If attribute is type and it's None, and no simple or complex content,
return the default type "xsd:anyType"
"""
value = XMLSchemaComponent.getAttribute(self, attribute)
if attribute != 'type' or value is not None:
... | [
"def",
"getAttribute",
"(",
"self",
",",
"attribute",
")",
":",
"value",
"=",
"XMLSchemaComponent",
".",
"getAttribute",
"(",
"self",
",",
"attribute",
")",
"if",
"attribute",
"!=",
"'type'",
"or",
"value",
"is",
"not",
"None",
":",
"return",
"value",
"if"... | return attribute.
If attribute is type and it's None, and no simple or complex content,
return the default type "xsd:anyType" | [
"return",
"attribute",
".",
"If",
"attribute",
"is",
"type",
"and",
"it",
"s",
"None",
"and",
"no",
"simple",
"or",
"complex",
"content",
"return",
"the",
"default",
"type",
"xsd",
":",
"anyType"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L1903-L1928 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | ElementDeclaration.getTypeDefinition | def getTypeDefinition(self, attribute=None):
"""If attribute is None, "type" is assumed, return the corresponding
representation of the global type definition (TypeDefinition),
or the local definition if don't find "type". To maintain backwards
compat, if attribute is provided call base... | python | def getTypeDefinition(self, attribute=None):
"""If attribute is None, "type" is assumed, return the corresponding
representation of the global type definition (TypeDefinition),
or the local definition if don't find "type". To maintain backwards
compat, if attribute is provided call base... | [
"def",
"getTypeDefinition",
"(",
"self",
",",
"attribute",
"=",
"None",
")",
":",
"if",
"attribute",
":",
"return",
"XMLSchemaComponent",
".",
"getTypeDefinition",
"(",
"self",
",",
"attribute",
")",
"gt",
"=",
"XMLSchemaComponent",
".",
"getTypeDefinition",
"("... | If attribute is None, "type" is assumed, return the corresponding
representation of the global type definition (TypeDefinition),
or the local definition if don't find "type". To maintain backwards
compat, if attribute is provided call base class method. | [
"If",
"attribute",
"is",
"None",
"type",
"is",
"assumed",
"return",
"the",
"corresponding",
"representation",
"of",
"the",
"global",
"type",
"definition",
"(",
"TypeDefinition",
")",
"or",
"the",
"local",
"definition",
"if",
"don",
"t",
"find",
"type",
".",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L1933-L1944 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | LocalElementDeclaration.isQualified | def isQualified(self):
"""
Local elements can be qualified or unqualifed according
to the attribute form, or the elementFormDefault. By default
local elements are unqualified.
"""
form = self.getAttribute('form')
if form == 'qualified':
return True
if... | python | def isQualified(self):
"""
Local elements can be qualified or unqualifed according
to the attribute form, or the elementFormDefault. By default
local elements are unqualified.
"""
form = self.getAttribute('form')
if form == 'qualified':
return True
if... | [
"def",
"isQualified",
"(",
"self",
")",
":",
"form",
"=",
"self",
".",
"getAttribute",
"(",
"'form'",
")",
"if",
"form",
"==",
"'qualified'",
":",
"return",
"True",
"if",
"form",
"==",
"'unqualified'",
":",
"return",
"False",
"raise",
"SchemaError",
",",
... | Local elements can be qualified or unqualifed according
to the attribute form, or the elementFormDefault. By default
local elements are unqualified. | [
"Local",
"elements",
"can",
"be",
"qualified",
"or",
"unqualifed",
"according",
"to",
"the",
"attribute",
"form",
"or",
"the",
"elementFormDefault",
".",
"By",
"default",
"local",
"elements",
"are",
"unqualified",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L2019-L2030 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/XMLSchema.py | ElementReference.getElementDeclaration | def getElementDeclaration(self, attribute=None):
"""If attribute is None, "ref" is assumed, return the corresponding
representation of the global element declaration (ElementDeclaration),
To maintain backwards compat, if attribute is provided call base class method.
"""
if attrib... | python | def getElementDeclaration(self, attribute=None):
"""If attribute is None, "ref" is assumed, return the corresponding
representation of the global element declaration (ElementDeclaration),
To maintain backwards compat, if attribute is provided call base class method.
"""
if attrib... | [
"def",
"getElementDeclaration",
"(",
"self",
",",
"attribute",
"=",
"None",
")",
":",
"if",
"attribute",
":",
"return",
"XMLSchemaComponent",
".",
"getElementDeclaration",
"(",
"self",
",",
"attribute",
")",
"return",
"XMLSchemaComponent",
".",
"getElementDeclaratio... | If attribute is None, "ref" is assumed, return the corresponding
representation of the global element declaration (ElementDeclaration),
To maintain backwards compat, if attribute is provided call base class method. | [
"If",
"attribute",
"is",
"None",
"ref",
"is",
"assumed",
"return",
"the",
"corresponding",
"representation",
"of",
"the",
"global",
"element",
"declaration",
"(",
"ElementDeclaration",
")",
"To",
"maintain",
"backwards",
"compat",
"if",
"attribute",
"is",
"provide... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/XMLSchema.py#L2059-L2066 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.