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 |
|---|---|---|---|---|---|---|---|---|---|---|
Nixiware/viper | nx/viper/application.py | Application._getInterfaces | def _getInterfaces(self):
"""
Load application communication interfaces.
:return: <dict>
"""
interfaces = {}
interfacesPath = os.path.join("application", "interface")
interfaceList = os.listdir(interfacesPath)
for file in interfaceList:
inte... | python | def _getInterfaces(self):
"""
Load application communication interfaces.
:return: <dict>
"""
interfaces = {}
interfacesPath = os.path.join("application", "interface")
interfaceList = os.listdir(interfacesPath)
for file in interfaceList:
inte... | [
"def",
"_getInterfaces",
"(",
"self",
")",
":",
"interfaces",
"=",
"{",
"}",
"interfacesPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"application\"",
",",
"\"interface\"",
")",
"interfaceList",
"=",
"os",
".",
"listdir",
"(",
"interfacesPath",
")",
"... | Load application communication interfaces.
:return: <dict> | [
"Load",
"application",
"communication",
"interfaces",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L62-L98 |
Nixiware/viper | nx/viper/application.py | Application._getModules | def _getModules(self):
"""
Import and load application modules.
:return: <dict>
"""
modules = {}
modulesPath = os.path.join("application", "module")
moduleList = os.listdir(modulesPath)
for moduleName in moduleList:
modulePath = os.path.join(... | python | def _getModules(self):
"""
Import and load application modules.
:return: <dict>
"""
modules = {}
modulesPath = os.path.join("application", "module")
moduleList = os.listdir(modulesPath)
for moduleName in moduleList:
modulePath = os.path.join(... | [
"def",
"_getModules",
"(",
"self",
")",
":",
"modules",
"=",
"{",
"}",
"modulesPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"application\"",
",",
"\"module\"",
")",
"moduleList",
"=",
"os",
".",
"listdir",
"(",
"modulesPath",
")",
"for",
"moduleNam... | Import and load application modules.
:return: <dict> | [
"Import",
"and",
"load",
"application",
"modules",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L111-L138 |
Nixiware/viper | nx/viper/application.py | Application.addModel | def addModel(self, moduleName, modelName, model):
"""
Add a model instance to the application model pool.
:param moduleName: <str> module name in which the model is located
:param modelName: <str> model name
:param model: <object> model instance
:return: <void>
"... | python | def addModel(self, moduleName, modelName, model):
"""
Add a model instance to the application model pool.
:param moduleName: <str> module name in which the model is located
:param modelName: <str> model name
:param model: <object> model instance
:return: <void>
"... | [
"def",
"addModel",
"(",
"self",
",",
"moduleName",
",",
"modelName",
",",
"model",
")",
":",
"modelIdentifier",
"=",
"\"{}.{}\"",
".",
"format",
"(",
"moduleName",
",",
"modelName",
")",
"if",
"modelIdentifier",
"not",
"in",
"self",
".",
"_models",
":",
"s... | Add a model instance to the application model pool.
:param moduleName: <str> module name in which the model is located
:param modelName: <str> model name
:param model: <object> model instance
:return: <void> | [
"Add",
"a",
"model",
"instance",
"to",
"the",
"application",
"model",
"pool",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L155-L171 |
Nixiware/viper | nx/viper/application.py | Application.getModel | def getModel(self, modelIdentifier):
"""
Return the requested model.
:param modelIdentifier: <str> model identifier
:return: <object> model instance
"""
if modelIdentifier in self._models:
return self._models[modelIdentifier]
else:
message... | python | def getModel(self, modelIdentifier):
"""
Return the requested model.
:param modelIdentifier: <str> model identifier
:return: <object> model instance
"""
if modelIdentifier in self._models:
return self._models[modelIdentifier]
else:
message... | [
"def",
"getModel",
"(",
"self",
",",
"modelIdentifier",
")",
":",
"if",
"modelIdentifier",
"in",
"self",
".",
"_models",
":",
"return",
"self",
".",
"_models",
"[",
"modelIdentifier",
"]",
"else",
":",
"message",
"=",
"\"Application - getModel() - \"",
"\"Model ... | Return the requested model.
:param modelIdentifier: <str> model identifier
:return: <object> model instance | [
"Return",
"the",
"requested",
"model",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L173-L186 |
Nixiware/viper | nx/viper/application.py | Application._loadViperServices | def _loadViperServices(self):
"""
Load application bundled services.
:return: <void>
"""
servicesPath = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"service"
)
for serviceFile in os.listdir(servicesPath):
if serv... | python | def _loadViperServices(self):
"""
Load application bundled services.
:return: <void>
"""
servicesPath = os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"service"
)
for serviceFile in os.listdir(servicesPath):
if serv... | [
"def",
"_loadViperServices",
"(",
"self",
")",
":",
"servicesPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
",",
"\"service\"",
")",
"for",
"serv... | Load application bundled services.
:return: <void> | [
"Load",
"application",
"bundled",
"services",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L191-L223 |
Nixiware/viper | nx/viper/application.py | Application.addService | def addService(self, moduleName, serviceName, service):
"""
Add a service instance to the application service pool.
:param moduleName: <str> module name in which the service is located
:param serviceName: <str> service name
:param service: <object> service instance
:retu... | python | def addService(self, moduleName, serviceName, service):
"""
Add a service instance to the application service pool.
:param moduleName: <str> module name in which the service is located
:param serviceName: <str> service name
:param service: <object> service instance
:retu... | [
"def",
"addService",
"(",
"self",
",",
"moduleName",
",",
"serviceName",
",",
"service",
")",
":",
"serviceIdentifier",
"=",
"\"{}.{}\"",
".",
"format",
"(",
"moduleName",
",",
"serviceName",
")",
"if",
"serviceIdentifier",
"not",
"in",
"self",
".",
"_services... | Add a service instance to the application service pool.
:param moduleName: <str> module name in which the service is located
:param serviceName: <str> service name
:param service: <object> service instance
:return: <void> | [
"Add",
"a",
"service",
"instance",
"to",
"the",
"application",
"service",
"pool",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L225-L241 |
Nixiware/viper | nx/viper/application.py | Application.getService | def getService(self, serviceIdentifier):
"""
Return the requested service instance.
:param serviceIdentifier: <str> service identifier
:return: <object> service instance
"""
if serviceIdentifier in self._services:
return self._services[serviceIdentifier]
... | python | def getService(self, serviceIdentifier):
"""
Return the requested service instance.
:param serviceIdentifier: <str> service identifier
:return: <object> service instance
"""
if serviceIdentifier in self._services:
return self._services[serviceIdentifier]
... | [
"def",
"getService",
"(",
"self",
",",
"serviceIdentifier",
")",
":",
"if",
"serviceIdentifier",
"in",
"self",
".",
"_services",
":",
"return",
"self",
".",
"_services",
"[",
"serviceIdentifier",
"]",
"else",
":",
"message",
"=",
"\"Application - getService() - \"... | Return the requested service instance.
:param serviceIdentifier: <str> service identifier
:return: <object> service instance | [
"Return",
"the",
"requested",
"service",
"instance",
"."
] | train | https://github.com/Nixiware/viper/blob/fbe6057facd8d46103e9955880dfd99e63b7acb3/nx/viper/application.py#L243-L256 |
moertle/pyaas | pyaas/settings.py | load | def load(settings=None, namespace=None, prefix=None):
"""
Call this guy to init pyaas stuffs
:param settings: Alternative name of ini file to load
:param namespace: Namespace is used to derive paths, pass '' for an empty namespace
:param prefix: The root path of the app
:return: None
"""
... | python | def load(settings=None, namespace=None, prefix=None):
"""
Call this guy to init pyaas stuffs
:param settings: Alternative name of ini file to load
:param namespace: Namespace is used to derive paths, pass '' for an empty namespace
:param prefix: The root path of the app
:return: None
"""
... | [
"def",
"load",
"(",
"settings",
"=",
"None",
",",
"namespace",
"=",
"None",
",",
"prefix",
"=",
"None",
")",
":",
"parent",
"=",
"pyaas",
".",
"util",
".",
"getParent",
"(",
")",
"script_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"parent",
... | Call this guy to init pyaas stuffs
:param settings: Alternative name of ini file to load
:param namespace: Namespace is used to derive paths, pass '' for an empty namespace
:param prefix: The root path of the app
:return: None | [
"Call",
"this",
"guy",
"to",
"init",
"pyaas",
"stuffs",
":",
"param",
"settings",
":",
"Alternative",
"name",
"of",
"ini",
"file",
"to",
"load",
":",
"param",
"namespace",
":",
"Namespace",
"is",
"used",
"to",
"derive",
"paths",
"pass",
"for",
"an",
"emp... | train | https://github.com/moertle/pyaas/blob/fc6a4cc94d4d6767df449fb3293d0ecb97e7e268/pyaas/settings.py#L33-L124 |
neumark/microcli | example.py | Calculator.add | def add(self, *number):
"""Adds all parameters interpreted as integers"""
return self._format_result(sum(
# positional arguments are always strings
[int(n) for n in number])) | python | def add(self, *number):
"""Adds all parameters interpreted as integers"""
return self._format_result(sum(
# positional arguments are always strings
[int(n) for n in number])) | [
"def",
"add",
"(",
"self",
",",
"*",
"number",
")",
":",
"return",
"self",
".",
"_format_result",
"(",
"sum",
"(",
"# positional arguments are always strings",
"[",
"int",
"(",
"n",
")",
"for",
"n",
"in",
"number",
"]",
")",
")"
] | Adds all parameters interpreted as integers | [
"Adds",
"all",
"parameters",
"interpreted",
"as",
"integers"
] | train | https://github.com/neumark/microcli/blob/fa31a35a95f63593ca12d246a5a84e2dff522dd6/example.py#L27-L31 |
neumark/microcli | example.py | Calculator.subtract | def subtract(self, number1, number2):
"""Subtracts number2 from number1"""
return self._format_result(int(number1) - int(number2)) | python | def subtract(self, number1, number2):
"""Subtracts number2 from number1"""
return self._format_result(int(number1) - int(number2)) | [
"def",
"subtract",
"(",
"self",
",",
"number1",
",",
"number2",
")",
":",
"return",
"self",
".",
"_format_result",
"(",
"int",
"(",
"number1",
")",
"-",
"int",
"(",
"number2",
")",
")"
] | Subtracts number2 from number1 | [
"Subtracts",
"number2",
"from",
"number1"
] | train | https://github.com/neumark/microcli/blob/fa31a35a95f63593ca12d246a5a84e2dff522dd6/example.py#L34-L36 |
neumark/microcli | example.py | Calculator.log | def log(self, x, base=2):
"""Computes the logarithm of x with the given base
(the default base is 2)."""
return self._format_result(log(float(x), base)) | python | def log(self, x, base=2):
"""Computes the logarithm of x with the given base
(the default base is 2)."""
return self._format_result(log(float(x), base)) | [
"def",
"log",
"(",
"self",
",",
"x",
",",
"base",
"=",
"2",
")",
":",
"return",
"self",
".",
"_format_result",
"(",
"log",
"(",
"float",
"(",
"x",
")",
",",
"base",
")",
")"
] | Computes the logarithm of x with the given base
(the default base is 2). | [
"Computes",
"the",
"logarithm",
"of",
"x",
"with",
"the",
"given",
"base",
"(",
"the",
"default",
"base",
"is",
"2",
")",
"."
] | train | https://github.com/neumark/microcli/blob/fa31a35a95f63593ca12d246a5a84e2dff522dd6/example.py#L39-L42 |
johnnoone/facts | facts/logical.py | Logical.items | async def items(self):
"""Expose all grafts.
"""
accumulator = Accumulator()
for graft in load_grafts():
accumulator.spawn(graft())
response = await accumulator.join()
return response.items() | python | async def items(self):
"""Expose all grafts.
"""
accumulator = Accumulator()
for graft in load_grafts():
accumulator.spawn(graft())
response = await accumulator.join()
return response.items() | [
"async",
"def",
"items",
"(",
"self",
")",
":",
"accumulator",
"=",
"Accumulator",
"(",
")",
"for",
"graft",
"in",
"load_grafts",
"(",
")",
":",
"accumulator",
".",
"spawn",
"(",
"graft",
"(",
")",
")",
"response",
"=",
"await",
"accumulator",
".",
"jo... | Expose all grafts. | [
"Expose",
"all",
"grafts",
"."
] | train | https://github.com/johnnoone/facts/blob/82d38a46c15d9c01200445526f4c0d1825fc1e51/facts/logical.py#L12-L20 |
radjkarl/fancyTools | fancytools/geometry/polygon.py | area | def area(x,y):
"""
Calculate the area of a polygon given as x(...),y(...)
Implementation of Shoelace formula
"""
# http://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates
return 0.5 * np.abs(np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1))) | python | def area(x,y):
"""
Calculate the area of a polygon given as x(...),y(...)
Implementation of Shoelace formula
"""
# http://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates
return 0.5 * np.abs(np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1))) | [
"def",
"area",
"(",
"x",
",",
"y",
")",
":",
"# http://stackoverflow.com/questions/24467972/calculate-area-of-polygon-given-x-y-coordinates",
"return",
"0.5",
"*",
"np",
".",
"abs",
"(",
"np",
".",
"dot",
"(",
"x",
",",
"np",
".",
"roll",
"(",
"y",
",",
"1",
... | Calculate the area of a polygon given as x(...),y(...)
Implementation of Shoelace formula | [
"Calculate",
"the",
"area",
"of",
"a",
"polygon",
"given",
"as",
"x",
"(",
"...",
")",
"y",
"(",
"...",
")",
"Implementation",
"of",
"Shoelace",
"formula"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polygon.py#L12-L18 |
radjkarl/fancyTools | fancytools/geometry/polygon.py | pointInsidePolygon | def pointInsidePolygon(x, y, poly):
"""
Determine if a point is inside a given polygon or not
Polygon is a list of (x,y) pairs.
[code taken from: http://www.ariel.com.au/a/python-point-int-poly.html]
let's make an easy square:
>>> poly = [ (0,0),\
(1,0),\
(1,... | python | def pointInsidePolygon(x, y, poly):
"""
Determine if a point is inside a given polygon or not
Polygon is a list of (x,y) pairs.
[code taken from: http://www.ariel.com.au/a/python-point-int-poly.html]
let's make an easy square:
>>> poly = [ (0,0),\
(1,0),\
(1,... | [
"def",
"pointInsidePolygon",
"(",
"x",
",",
"y",
",",
"poly",
")",
":",
"n",
"=",
"len",
"(",
"poly",
")",
"inside",
"=",
"False",
"p1x",
",",
"p1y",
"=",
"poly",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"n",
"+",
"1",
")",
":",
"p2x",
... | Determine if a point is inside a given polygon or not
Polygon is a list of (x,y) pairs.
[code taken from: http://www.ariel.com.au/a/python-point-int-poly.html]
let's make an easy square:
>>> poly = [ (0,0),\
(1,0),\
(1,1),\
(0,1) ]
>>> pointInsid... | [
"Determine",
"if",
"a",
"point",
"is",
"inside",
"a",
"given",
"polygon",
"or",
"not",
"Polygon",
"is",
"a",
"list",
"of",
"(",
"x",
"y",
")",
"pairs",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/geometry/polygon.py#L43-L74 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/settings.py | conf_merger | def conf_merger(user_dict, variable):
"""
Merge global configuration with user's personal configuration.
Global configuration has always higher priority.
"""
if variable not in globals().keys():
raise NameError("Unknown variable '%s'." % variable)
if variable not in user_dict:
... | python | def conf_merger(user_dict, variable):
"""
Merge global configuration with user's personal configuration.
Global configuration has always higher priority.
"""
if variable not in globals().keys():
raise NameError("Unknown variable '%s'." % variable)
if variable not in user_dict:
... | [
"def",
"conf_merger",
"(",
"user_dict",
",",
"variable",
")",
":",
"if",
"variable",
"not",
"in",
"globals",
"(",
")",
".",
"keys",
"(",
")",
":",
"raise",
"NameError",
"(",
"\"Unknown variable '%s'.\"",
"%",
"variable",
")",
"if",
"variable",
"not",
"in",... | Merge global configuration with user's personal configuration.
Global configuration has always higher priority. | [
"Merge",
"global",
"configuration",
"with",
"user",
"s",
"personal",
"configuration",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/settings.py#L121-L133 |
edeposit/edeposit.amqp.ftp | src/edeposit/amqp/ftp/settings.py | get_all_constants | def get_all_constants():
"""
Get list of all uppercase, non-private globals (doesn't start with ``_``).
Returns:
list: Uppercase names defined in `globals()` (variables from this \
module).
"""
return filter(
lambda key: key.upper() == key and type(globals()[key]) in _... | python | def get_all_constants():
"""
Get list of all uppercase, non-private globals (doesn't start with ``_``).
Returns:
list: Uppercase names defined in `globals()` (variables from this \
module).
"""
return filter(
lambda key: key.upper() == key and type(globals()[key]) in _... | [
"def",
"get_all_constants",
"(",
")",
":",
"return",
"filter",
"(",
"lambda",
"key",
":",
"key",
".",
"upper",
"(",
")",
"==",
"key",
"and",
"type",
"(",
"globals",
"(",
")",
"[",
"key",
"]",
")",
"in",
"_ALLOWED",
",",
"filter",
"(",
"# filter _PRIV... | Get list of all uppercase, non-private globals (doesn't start with ``_``).
Returns:
list: Uppercase names defined in `globals()` (variables from this \
module). | [
"Get",
"list",
"of",
"all",
"uppercase",
"non",
"-",
"private",
"globals",
"(",
"doesn",
"t",
"start",
"with",
"_",
")",
"."
] | train | https://github.com/edeposit/edeposit.amqp.ftp/blob/fcdcbffb6e5d194e1bb4f85f0b8eaa9dbb08aa71/src/edeposit/amqp/ftp/settings.py#L149-L164 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.get_connection | def get_connection(self, host, port):
"""
Returns a ``StrictRedis`` connection instance.
"""
return beanstalkc.Connection(
host=host,
port=port
) | python | def get_connection(self, host, port):
"""
Returns a ``StrictRedis`` connection instance.
"""
return beanstalkc.Connection(
host=host,
port=port
) | [
"def",
"get_connection",
"(",
"self",
",",
"host",
",",
"port",
")",
":",
"return",
"beanstalkc",
".",
"Connection",
"(",
"host",
"=",
"host",
",",
"port",
"=",
"port",
")"
] | Returns a ``StrictRedis`` connection instance. | [
"Returns",
"a",
"StrictRedis",
"connection",
"instance",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L25-L32 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.len | def len(self, queue_name):
"""
Returns the length of the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The length of the queue
:rtype: integer
"""
try:
... | python | def len(self, queue_name):
"""
Returns the length of the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The length of the queue
:rtype: integer
"""
try:
... | [
"def",
"len",
"(",
"self",
",",
"queue_name",
")",
":",
"try",
":",
"stats",
"=",
"self",
".",
"conn",
".",
"stats_tube",
"(",
"queue_name",
")",
"except",
"beanstalkc",
".",
"CommandFailed",
"as",
"err",
":",
"if",
"err",
"[",
"1",
"]",
"==",
"'NOT_... | Returns the length of the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The length of the queue
:rtype: integer | [
"Returns",
"the",
"length",
"of",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L34-L53 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.drop_all | def drop_all(self, queue_name):
"""
Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
"""
# This is very inefficient, but Beanstalk (as of v1.10) doesn't support
... | python | def drop_all(self, queue_name):
"""
Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
"""
# This is very inefficient, but Beanstalk (as of v1.10) doesn't support
... | [
"def",
"drop_all",
"(",
"self",
",",
"queue_name",
")",
":",
"# This is very inefficient, but Beanstalk (as of v1.10) doesn't support",
"# deleting an entire tube.",
"queue_length",
"=",
"self",
".",
"len",
"(",
"queue_name",
")",
"self",
".",
"_only_watch_from",
"(",
"qu... | Drops all the task in the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string | [
"Drops",
"all",
"the",
"task",
"in",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L55-L72 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.push | def push(self, queue_name, task_id, data):
"""
Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
... | python | def push(self, queue_name, task_id, data):
"""
Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
... | [
"def",
"push",
"(",
"self",
",",
"queue_name",
",",
"task_id",
",",
"data",
")",
":",
"# Beanstalk doesn't let you specify a task id.",
"self",
".",
"conn",
".",
"use",
"(",
"queue_name",
")",
"return",
"self",
".",
"conn",
".",
"put",
"(",
"data",
")"
] | Pushes a task onto the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
:param data: The relevant data for the task.
:type ... | [
"Pushes",
"a",
"task",
"onto",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L74-L90 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.pop | def pop(self, queue_name):
"""
Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string
"""
self._only_watch_from(... | python | def pop(self, queue_name):
"""
Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string
"""
self._only_watch_from(... | [
"def",
"pop",
"(",
"self",
",",
"queue_name",
")",
":",
"self",
".",
"_only_watch_from",
"(",
"queue_name",
")",
"job",
"=",
"self",
".",
"conn",
".",
"reserve",
"(",
"timeout",
"=",
"0",
")",
"job",
".",
"delete",
"(",
")",
"return",
"job",
".",
"... | Pops a task off the queue.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:returns: The data for the task.
:rtype: string | [
"Pops",
"a",
"task",
"off",
"the",
"queue",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L104-L118 |
toastdriven/alligator | alligator/backends/beanstalk_backend.py | Client.get | def get(self, queue_name, task_id):
"""
Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id:... | python | def get(self, queue_name, task_id):
"""
Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id:... | [
"def",
"get",
"(",
"self",
",",
"queue_name",
",",
"task_id",
")",
":",
"self",
".",
"_only_watch_from",
"(",
"queue_name",
")",
"job",
"=",
"self",
".",
"conn",
".",
"peek",
"(",
"task_id",
")",
"if",
"not",
"job",
":",
"return",
"job",
".",
"delete... | Pops a specific task off the queue by identifier.
:param queue_name: The name of the queue. Usually handled by the
``Gator`` instance.
:type queue_name: string
:param task_id: The identifier of the task.
:type task_id: string
:returns: The data for the task.
... | [
"Pops",
"a",
"specific",
"task",
"off",
"the",
"queue",
"by",
"identifier",
"."
] | train | https://github.com/toastdriven/alligator/blob/f18bcb35b350fc6b0886393f5246d69c892b36c7/alligator/backends/beanstalk_backend.py#L120-L141 |
dossier/dossier.models | dossier/models/pairwise.py | add_facets | def add_facets(engine_result, facet_features=None):
'''Adds facets to search results.
Construct a new result payload with `facets` added as a new
top-level property that carries a mapping from unicode strings to
lists of content_ids. The `facet_features` lists the names of
:class:`~dossier.fc.Stri... | python | def add_facets(engine_result, facet_features=None):
'''Adds facets to search results.
Construct a new result payload with `facets` added as a new
top-level property that carries a mapping from unicode strings to
lists of content_ids. The `facet_features` lists the names of
:class:`~dossier.fc.Stri... | [
"def",
"add_facets",
"(",
"engine_result",
",",
"facet_features",
"=",
"None",
")",
":",
"if",
"facet_features",
"is",
"None",
":",
"facet_features",
"=",
"[",
"'bowNP_sip'",
"]",
"phrases",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"r... | Adds facets to search results.
Construct a new result payload with `facets` added as a new
top-level property that carries a mapping from unicode strings to
lists of content_ids. The `facet_features` lists the names of
:class:`~dossier.fc.StringCounter` features in each result
:class:`~dossier.fc.... | [
"Adds",
"facets",
"to",
"search",
"results",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L98-L120 |
dossier/dossier.models | dossier/models/pairwise.py | labels_to_indexed_coref_values | def labels_to_indexed_coref_values(content_objs, labels):
'''[(content_id, FeatureCollection)] -> [Label] -> [({-1,1}, i, j)]
where 0 <= i, j < len(content_objs).
'''
cids_to_idx = {}
for i, (content_id, _) in enumerate(content_objs):
cids_to_idx[content_id] = i
idx = lambda cid: cids_t... | python | def labels_to_indexed_coref_values(content_objs, labels):
'''[(content_id, FeatureCollection)] -> [Label] -> [({-1,1}, i, j)]
where 0 <= i, j < len(content_objs).
'''
cids_to_idx = {}
for i, (content_id, _) in enumerate(content_objs):
cids_to_idx[content_id] = i
idx = lambda cid: cids_t... | [
"def",
"labels_to_indexed_coref_values",
"(",
"content_objs",
",",
"labels",
")",
":",
"cids_to_idx",
"=",
"{",
"}",
"for",
"i",
",",
"(",
"content_id",
",",
"_",
")",
"in",
"enumerate",
"(",
"content_objs",
")",
":",
"cids_to_idx",
"[",
"content_id",
"]",
... | [(content_id, FeatureCollection)] -> [Label] -> [({-1,1}, i, j)]
where 0 <= i, j < len(content_objs). | [
"[",
"(",
"content_id",
"FeatureCollection",
")",
"]",
"-",
">",
"[",
"Label",
"]",
"-",
">",
"[",
"(",
"{",
"-",
"1",
"1",
"}",
"i",
"j",
")",
"]"
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L485-L498 |
dossier/dossier.models | dossier/models/pairwise.py | vectorizable_features | def vectorizable_features(fcs):
'''Discovers the ordered set of vectorizable features in ``fcs``.
Returns a list of feature names, sorted lexicographically.
Feature names are only included if the corresponding
features are vectorizable (i.e., they are an instance of
:class:`collections.Mapping`).
... | python | def vectorizable_features(fcs):
'''Discovers the ordered set of vectorizable features in ``fcs``.
Returns a list of feature names, sorted lexicographically.
Feature names are only included if the corresponding
features are vectorizable (i.e., they are an instance of
:class:`collections.Mapping`).
... | [
"def",
"vectorizable_features",
"(",
"fcs",
")",
":",
"is_mapping",
"=",
"lambda",
"obj",
":",
"isinstance",
"(",
"obj",
",",
"collections",
".",
"Mapping",
")",
"return",
"sorted",
"(",
"set",
"(",
"[",
"name",
"for",
"fc",
"in",
"fcs",
"for",
"name",
... | Discovers the ordered set of vectorizable features in ``fcs``.
Returns a list of feature names, sorted lexicographically.
Feature names are only included if the corresponding
features are vectorizable (i.e., they are an instance of
:class:`collections.Mapping`). | [
"Discovers",
"the",
"ordered",
"set",
"of",
"vectorizable",
"features",
"in",
"fcs",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L501-L510 |
dossier/dossier.models | dossier/models/pairwise.py | dissimilarities | def dissimilarities(feature_names, fcs):
'''Computes the pairwise dissimilarity matrices.
This returns a dictionary mapping each name in ``feature_names``
to a pairwise dissimilarities matrix. The dissimilaritiy scores
correspond to ``1 - kernel`` between each feature of each
pair of feature collec... | python | def dissimilarities(feature_names, fcs):
'''Computes the pairwise dissimilarity matrices.
This returns a dictionary mapping each name in ``feature_names``
to a pairwise dissimilarities matrix. The dissimilaritiy scores
correspond to ``1 - kernel`` between each feature of each
pair of feature collec... | [
"def",
"dissimilarities",
"(",
"feature_names",
",",
"fcs",
")",
":",
"dis",
"=",
"{",
"}",
"for",
"count",
",",
"name",
"in",
"enumerate",
"(",
"feature_names",
",",
"1",
")",
":",
"logger",
".",
"info",
"(",
"'computing pairwise dissimilarity matrix '",
"'... | Computes the pairwise dissimilarity matrices.
This returns a dictionary mapping each name in ``feature_names``
to a pairwise dissimilarities matrix. The dissimilaritiy scores
correspond to ``1 - kernel`` between each feature of each
pair of feature collections in ``fcs``.
(The kernel used is curre... | [
"Computes",
"the",
"pairwise",
"dissimilarity",
"matrices",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L513-L536 |
dossier/dossier.models | dossier/models/pairwise.py | PairwiseFeatureLearner.probabilities | def probabilities(self):
'''Trains a model and predicts recommendations.
If the query feature collection could not be found or if there
is insufficient training data, an empty list is returned.
Otherwise, a list of content objects (tuples of content
id and feature collection) a... | python | def probabilities(self):
'''Trains a model and predicts recommendations.
If the query feature collection could not be found or if there
is insufficient training data, an empty list is returned.
Otherwise, a list of content objects (tuples of content
id and feature collection) a... | [
"def",
"probabilities",
"(",
"self",
")",
":",
"self",
".",
"query_fc",
"=",
"self",
".",
"store",
".",
"get",
"(",
"self",
".",
"query_content_id",
")",
"if",
"self",
".",
"query_fc",
"is",
"None",
":",
"logger",
".",
"warning",
"(",
"'Could not find FC... | Trains a model and predicts recommendations.
If the query feature collection could not be found or if there
is insufficient training data, an empty list is returned.
Otherwise, a list of content objects (tuples of content
id and feature collection) and probabilities is returned.
... | [
"Trains",
"a",
"model",
"and",
"predicts",
"recommendations",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L210-L269 |
dossier/dossier.models | dossier/models/pairwise.py | PairwiseFeatureLearner.train | def train(self, content_objs, idx_labels):
'''Trains and returns a model using sklearn.
If there are new labels to add, they can be added, returns an
sklearn model which can be used for prediction and getting
features.
This method may return ``None`` if there is insufficient
... | python | def train(self, content_objs, idx_labels):
'''Trains and returns a model using sklearn.
If there are new labels to add, they can be added, returns an
sklearn model which can be used for prediction and getting
features.
This method may return ``None`` if there is insufficient
... | [
"def",
"train",
"(",
"self",
",",
"content_objs",
",",
"idx_labels",
")",
":",
"# We have insufficient training data when there is only one or",
"# fewer classes of labels.",
"if",
"len",
"(",
"set",
"(",
"[",
"lab",
"[",
"0",
"]",
"for",
"lab",
"in",
"idx_labels",
... | Trains and returns a model using sklearn.
If there are new labels to add, they can be added, returns an
sklearn model which can be used for prediction and getting
features.
This method may return ``None`` if there is insufficient
training data to produce a model.
:para... | [
"Trains",
"and",
"returns",
"a",
"model",
"using",
"sklearn",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L271-L307 |
dossier/dossier.models | dossier/models/pairwise.py | PairwiseFeatureLearner.classify | def classify(self, feature_names, classifier, transformer, candidates,
query_fc=None):
'''Returns ``[probability]`` in correspondence with
``candidates``.
Where each ``probability`` corresponds to the probability that
the corresponding candidate is classified with a pos... | python | def classify(self, feature_names, classifier, transformer, candidates,
query_fc=None):
'''Returns ``[probability]`` in correspondence with
``candidates``.
Where each ``probability`` corresponds to the probability that
the corresponding candidate is classified with a pos... | [
"def",
"classify",
"(",
"self",
",",
"feature_names",
",",
"classifier",
",",
"transformer",
",",
"candidates",
",",
"query_fc",
"=",
"None",
")",
":",
"if",
"query_fc",
"is",
"None",
":",
"query_fc",
"=",
"self",
".",
"query_fc",
"dis",
"=",
"{",
"}",
... | Returns ``[probability]`` in correspondence with
``candidates``.
Where each ``probability`` corresponds to the probability that
the corresponding candidate is classified with a positive label
given the training data.
The list returned is in correspondence with the list of
... | [
"Returns",
"[",
"probability",
"]",
"in",
"correspondence",
"with",
"candidates",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L309-L339 |
dossier/dossier.models | dossier/models/pairwise.py | PairwiseFeatureLearner.content_objs_from_labels | def content_objs_from_labels(self, labels):
'''[Label] -> [(content_id, FeatureCollection)]'''
is_mapping = lambda obj: isinstance(obj, collections.Mapping)
def is_valid_fc((cid, fc)):
if fc is None:
return False
if sum(1 for name in fc if is_mapping(fc[na... | python | def content_objs_from_labels(self, labels):
'''[Label] -> [(content_id, FeatureCollection)]'''
is_mapping = lambda obj: isinstance(obj, collections.Mapping)
def is_valid_fc((cid, fc)):
if fc is None:
return False
if sum(1 for name in fc if is_mapping(fc[na... | [
"def",
"content_objs_from_labels",
"(",
"self",
",",
"labels",
")",
":",
"is_mapping",
"=",
"lambda",
"obj",
":",
"isinstance",
"(",
"obj",
",",
"collections",
".",
"Mapping",
")",
"def",
"is_valid_fc",
"(",
"(",
"cid",
",",
"fc",
")",
")",
":",
"if",
... | [Label] -> [(content_id, FeatureCollection)] | [
"[",
"Label",
"]",
"-",
">",
"[",
"(",
"content_id",
"FeatureCollection",
")",
"]"
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/pairwise.py#L468-L482 |
dossier/dossier.models | dossier/models/features/sip.py | noun_phrases_as_tokens | def noun_phrases_as_tokens(text):
'''Generate a bag of lists of unnormalized tokens representing noun
phrases from ``text``.
This is built around python's nltk library for getting Noun
Phrases (NPs). This is all documented in the NLTK Book
http://www.nltk.org/book/ch03.html and blog posts that cite... | python | def noun_phrases_as_tokens(text):
'''Generate a bag of lists of unnormalized tokens representing noun
phrases from ``text``.
This is built around python's nltk library for getting Noun
Phrases (NPs). This is all documented in the NLTK Book
http://www.nltk.org/book/ch03.html and blog posts that cite... | [
"def",
"noun_phrases_as_tokens",
"(",
"text",
")",
":",
"## from NLTK Book:",
"sentence_re",
"=",
"r'''(?x) # set flag to allow verbose regexps\n ([A-Z])(\\.[A-Z])+\\.? # abbreviations, e.g. U.S.A.\n | \\w+(-\\w+)* # words with optional internal hyphens\n | ... | Generate a bag of lists of unnormalized tokens representing noun
phrases from ``text``.
This is built around python's nltk library for getting Noun
Phrases (NPs). This is all documented in the NLTK Book
http://www.nltk.org/book/ch03.html and blog posts that cite the
book.
:rtype: list of lists... | [
"Generate",
"a",
"bag",
"of",
"lists",
"of",
"unnormalized",
"tokens",
"representing",
"noun",
"phrases",
"from",
"text",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/sip.py#L27-L87 |
dossier/dossier.models | dossier/models/features/sip.py | noun_phrases | def noun_phrases(text, included_unnormalized=False):
'''applies normalization to the terms found by noun_phrases_as_tokens
and joins on '_'.
:rtype: list of phrase strings with spaces replaced by ``_``.
'''
lemmatizer = nltk.WordNetLemmatizer()
stemmer = nltk.stem.porter.PorterStemmer()
d... | python | def noun_phrases(text, included_unnormalized=False):
'''applies normalization to the terms found by noun_phrases_as_tokens
and joins on '_'.
:rtype: list of phrase strings with spaces replaced by ``_``.
'''
lemmatizer = nltk.WordNetLemmatizer()
stemmer = nltk.stem.porter.PorterStemmer()
d... | [
"def",
"noun_phrases",
"(",
"text",
",",
"included_unnormalized",
"=",
"False",
")",
":",
"lemmatizer",
"=",
"nltk",
".",
"WordNetLemmatizer",
"(",
")",
"stemmer",
"=",
"nltk",
".",
"stem",
".",
"porter",
".",
"PorterStemmer",
"(",
")",
"def",
"normalize",
... | applies normalization to the terms found by noun_phrases_as_tokens
and joins on '_'.
:rtype: list of phrase strings with spaces replaced by ``_``. | [
"applies",
"normalization",
"to",
"the",
"terms",
"found",
"by",
"noun_phrases_as_tokens",
"and",
"joins",
"on",
"_",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/sip.py#L90-L118 |
crypto101/clarent | clarent/certificate.py | _makeCertificate | def _makeCertificate(key, email, _utcnow=datetime.utcnow):
"""Make the certificate for the client using the given key and e-mail
address.
"""
# Create a certificate for this key.
cert = X509()
cert.set_pubkey(key)
# Set the subject.
subject = cert.get_subject()
subject.CN = u"Crypt... | python | def _makeCertificate(key, email, _utcnow=datetime.utcnow):
"""Make the certificate for the client using the given key and e-mail
address.
"""
# Create a certificate for this key.
cert = X509()
cert.set_pubkey(key)
# Set the subject.
subject = cert.get_subject()
subject.CN = u"Crypt... | [
"def",
"_makeCertificate",
"(",
"key",
",",
"email",
",",
"_utcnow",
"=",
"datetime",
".",
"utcnow",
")",
":",
"# Create a certificate for this key.",
"cert",
"=",
"X509",
"(",
")",
"cert",
".",
"set_pubkey",
"(",
"key",
")",
"# Set the subject.",
"subject",
"... | Make the certificate for the client using the given key and e-mail
address. | [
"Make",
"the",
"certificate",
"for",
"the",
"client",
"using",
"the",
"given",
"key",
"and",
"e",
"-",
"mail",
"address",
"."
] | train | https://github.com/crypto101/clarent/blob/2b441d7933e85ee948cfb78506b7ca0a32e9588d/clarent/certificate.py#L19-L44 |
crypto101/clarent | clarent/certificate.py | makeCredentials | def makeCredentials(path, email):
"""Make credentials for the client from given e-mail address and store
them in the directory at path.
"""
key = _generateKey()
cert = _makeCertificate(key, email)
certPath = path.child("client.pem")
certPath.alwaysCreate = True
with certPath.open("wb"... | python | def makeCredentials(path, email):
"""Make credentials for the client from given e-mail address and store
them in the directory at path.
"""
key = _generateKey()
cert = _makeCertificate(key, email)
certPath = path.child("client.pem")
certPath.alwaysCreate = True
with certPath.open("wb"... | [
"def",
"makeCredentials",
"(",
"path",
",",
"email",
")",
":",
"key",
"=",
"_generateKey",
"(",
")",
"cert",
"=",
"_makeCertificate",
"(",
"key",
",",
"email",
")",
"certPath",
"=",
"path",
".",
"child",
"(",
"\"client.pem\"",
")",
"certPath",
".",
"alwa... | Make credentials for the client from given e-mail address and store
them in the directory at path. | [
"Make",
"credentials",
"for",
"the",
"client",
"from",
"given",
"e",
"-",
"mail",
"address",
"and",
"store",
"them",
"in",
"the",
"directory",
"at",
"path",
"."
] | train | https://github.com/crypto101/clarent/blob/2b441d7933e85ee948cfb78506b7ca0a32e9588d/clarent/certificate.py#L59-L72 |
crypto101/clarent | clarent/certificate.py | getContextFactory | def getContextFactory(path):
"""Get a context factory for the client from keys already stored at
path.
Raises IOError if the credentials didn't exist.
"""
with path.child("client.pem").open() as pemFile:
cert = PrivateCertificate.loadPEM(pemFile.read())
certOptions = cert.options() # ... | python | def getContextFactory(path):
"""Get a context factory for the client from keys already stored at
path.
Raises IOError if the credentials didn't exist.
"""
with path.child("client.pem").open() as pemFile:
cert = PrivateCertificate.loadPEM(pemFile.read())
certOptions = cert.options() # ... | [
"def",
"getContextFactory",
"(",
"path",
")",
":",
"with",
"path",
".",
"child",
"(",
"\"client.pem\"",
")",
".",
"open",
"(",
")",
"as",
"pemFile",
":",
"cert",
"=",
"PrivateCertificate",
".",
"loadPEM",
"(",
"pemFile",
".",
"read",
"(",
")",
")",
"ce... | Get a context factory for the client from keys already stored at
path.
Raises IOError if the credentials didn't exist. | [
"Get",
"a",
"context",
"factory",
"for",
"the",
"client",
"from",
"keys",
"already",
"stored",
"at",
"path",
"."
] | train | https://github.com/crypto101/clarent/blob/2b441d7933e85ee948cfb78506b7ca0a32e9588d/clarent/certificate.py#L76-L89 |
kankiri/pabiana | demos/smarthome/smarthome/__init__.py | schedule | def schedule(demand: dict, alterations: set, looped: set=None, altered: set=None):
"""Prioritizes Triggers called from outside."""
if looped is not None and len(demand) != len(looped):
for func in looped: del demand[func]
if keep_temp in demand:
demand.pop(increase_temp, None)
demand.pop(lower_temp, None)
eli... | python | def schedule(demand: dict, alterations: set, looped: set=None, altered: set=None):
"""Prioritizes Triggers called from outside."""
if looped is not None and len(demand) != len(looped):
for func in looped: del demand[func]
if keep_temp in demand:
demand.pop(increase_temp, None)
demand.pop(lower_temp, None)
eli... | [
"def",
"schedule",
"(",
"demand",
":",
"dict",
",",
"alterations",
":",
"set",
",",
"looped",
":",
"set",
"=",
"None",
",",
"altered",
":",
"set",
"=",
"None",
")",
":",
"if",
"looped",
"is",
"not",
"None",
"and",
"len",
"(",
"demand",
")",
"!=",
... | Prioritizes Triggers called from outside. | [
"Prioritizes",
"Triggers",
"called",
"from",
"outside",
"."
] | train | https://github.com/kankiri/pabiana/blob/74acfdd81e2a1cc411c37b9ee3d6905ce4b1a39b/demos/smarthome/smarthome/__init__.py#L41-L50 |
cykerway/logging-ext | logging_ext/__init__.py | d | def d(msg, *args, **kwargs):
'''
log a message at debug level;
'''
return logging.log(DEBUG, msg, *args, **kwargs) | python | def d(msg, *args, **kwargs):
'''
log a message at debug level;
'''
return logging.log(DEBUG, msg, *args, **kwargs) | [
"def",
"d",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"logging",
".",
"log",
"(",
"DEBUG",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | log a message at debug level; | [
"log",
"a",
"message",
"at",
"debug",
"level",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L24-L30 |
cykerway/logging-ext | logging_ext/__init__.py | v | def v(msg, *args, **kwargs):
'''
log a message at verbose level;
'''
return logging.log(VERBOSE, msg, *args, **kwargs) | python | def v(msg, *args, **kwargs):
'''
log a message at verbose level;
'''
return logging.log(VERBOSE, msg, *args, **kwargs) | [
"def",
"v",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"logging",
".",
"log",
"(",
"VERBOSE",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | log a message at verbose level; | [
"log",
"a",
"message",
"at",
"verbose",
"level",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L32-L38 |
cykerway/logging-ext | logging_ext/__init__.py | i | def i(msg, *args, **kwargs):
'''
log a message at info level;
'''
return logging.log(INFO, msg, *args, **kwargs) | python | def i(msg, *args, **kwargs):
'''
log a message at info level;
'''
return logging.log(INFO, msg, *args, **kwargs) | [
"def",
"i",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"logging",
".",
"log",
"(",
"INFO",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | log a message at info level; | [
"log",
"a",
"message",
"at",
"info",
"level",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L40-L46 |
cykerway/logging-ext | logging_ext/__init__.py | w | def w(msg, *args, **kwargs):
'''
log a message at warn level;
'''
return logging.log(WARN, msg, *args, **kwargs) | python | def w(msg, *args, **kwargs):
'''
log a message at warn level;
'''
return logging.log(WARN, msg, *args, **kwargs) | [
"def",
"w",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"logging",
".",
"log",
"(",
"WARN",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | log a message at warn level; | [
"log",
"a",
"message",
"at",
"warn",
"level",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L48-L54 |
cykerway/logging-ext | logging_ext/__init__.py | e | def e(msg, *args, **kwargs):
'''
log a message at error level;
'''
return logging.log(ERROR, msg, *args, **kwargs) | python | def e(msg, *args, **kwargs):
'''
log a message at error level;
'''
return logging.log(ERROR, msg, *args, **kwargs) | [
"def",
"e",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"logging",
".",
"log",
"(",
"ERROR",
",",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | log a message at error level; | [
"log",
"a",
"message",
"at",
"error",
"level",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L56-L62 |
cykerway/logging-ext | logging_ext/__init__.py | getLogger | def getLogger(name=None):
'''
return a logger instrumented with additional 1-letter logging methods;
'''
logger = logging.getLogger(name=name)
if not hasattr(logger, 'd'):
def d(self, msg, *args, **kwargs):
return self.log(DEBUG, msg, *args, **kwargs)
logger.d = types.... | python | def getLogger(name=None):
'''
return a logger instrumented with additional 1-letter logging methods;
'''
logger = logging.getLogger(name=name)
if not hasattr(logger, 'd'):
def d(self, msg, *args, **kwargs):
return self.log(DEBUG, msg, *args, **kwargs)
logger.d = types.... | [
"def",
"getLogger",
"(",
"name",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
"=",
"name",
")",
"if",
"not",
"hasattr",
"(",
"logger",
",",
"'d'",
")",
":",
"def",
"d",
"(",
"self",
",",
"msg",
",",
"*",
"args",... | return a logger instrumented with additional 1-letter logging methods; | [
"return",
"a",
"logger",
"instrumented",
"with",
"additional",
"1",
"-",
"letter",
"logging",
"methods",
";"
] | train | https://github.com/cykerway/logging-ext/blob/ed6700bdd602fa26276e1f194d255e74c7f255b4/logging_ext/__init__.py#L68-L101 |
mathiasbc/CoolLogger | coollogger/TimedCompressedRotatingFileHandler.py | TimedCompressedRotatingFileHandler.doRollover | def doRollover(self):
"""
do a rollover; in this case, a date/time stamp is appended to the filename
when the rollover happens. However, you want the file to be named for the
start of the interval, not the current time. If there is a backup count,
then we have to get a list of ... | python | def doRollover(self):
"""
do a rollover; in this case, a date/time stamp is appended to the filename
when the rollover happens. However, you want the file to be named for the
start of the interval, not the current time. If there is a backup count,
then we have to get a list of ... | [
"def",
"doRollover",
"(",
"self",
")",
":",
"self",
".",
"stream",
".",
"close",
"(",
")",
"# get the time that this sequence started at and make it a TimeTuple",
"t",
"=",
"self",
".",
"rolloverAt",
"-",
"self",
".",
"interval",
"timeTuple",
"=",
"time",
".",
"... | do a rollover; in this case, a date/time stamp is appended to the filename
when the rollover happens. However, you want the file to be named for the
start of the interval, not the current time. If there is a backup count,
then we have to get a list of matching filenames, sort them and remove
... | [
"do",
"a",
"rollover",
";",
"in",
"this",
"case",
"a",
"date",
"/",
"time",
"stamp",
"is",
"appended",
"to",
"the",
"filename",
"when",
"the",
"rollover",
"happens",
".",
"However",
"you",
"want",
"the",
"file",
"to",
"be",
"named",
"for",
"the",
"star... | train | https://github.com/mathiasbc/CoolLogger/blob/5b20cbff37707f41f7e81750f856a41acae607c7/coollogger/TimedCompressedRotatingFileHandler.py#L13-L46 |
Diaoul/pyextdirect | pyextdirect/router.py | create_instances | def create_instances(configuration):
"""Create necessary class instances from a configuration with no argument to the constructor
:param dict configuration: configuration dict like in :attr:`~pyextdirect.configuration.Base.configuration`
:return: a class-instance mapping
:rtype: dict
"""
insta... | python | def create_instances(configuration):
"""Create necessary class instances from a configuration with no argument to the constructor
:param dict configuration: configuration dict like in :attr:`~pyextdirect.configuration.Base.configuration`
:return: a class-instance mapping
:rtype: dict
"""
insta... | [
"def",
"create_instances",
"(",
"configuration",
")",
":",
"instances",
"=",
"{",
"}",
"for",
"methods",
"in",
"configuration",
".",
"itervalues",
"(",
")",
":",
"for",
"element",
"in",
"methods",
".",
"itervalues",
"(",
")",
":",
"if",
"not",
"isinstance"... | Create necessary class instances from a configuration with no argument to the constructor
:param dict configuration: configuration dict like in :attr:`~pyextdirect.configuration.Base.configuration`
:return: a class-instance mapping
:rtype: dict | [
"Create",
"necessary",
"class",
"instances",
"from",
"a",
"configuration",
"with",
"no",
"argument",
"to",
"the",
"constructor"
] | train | https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/router.py#L117-L133 |
Diaoul/pyextdirect | pyextdirect/router.py | Router.route | def route(self, data):
"""Route an Ext Direct request to the appropriate function(s) and provide the response(s)
:param data: Ext Direct request
:type data: json or dict or list
:return: appropriate response(s)
:rtype: json
"""
if isinstance(data, (dict, list)):... | python | def route(self, data):
"""Route an Ext Direct request to the appropriate function(s) and provide the response(s)
:param data: Ext Direct request
:type data: json or dict or list
:return: appropriate response(s)
:rtype: json
"""
if isinstance(data, (dict, list)):... | [
"def",
"route",
"(",
"self",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"(",
"dict",
",",
"list",
")",
")",
":",
"requests",
"=",
"data",
"else",
":",
"requests",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"if",
"not",
"isinst... | Route an Ext Direct request to the appropriate function(s) and provide the response(s)
:param data: Ext Direct request
:type data: json or dict or list
:return: appropriate response(s)
:rtype: json | [
"Route",
"an",
"Ext",
"Direct",
"request",
"to",
"the",
"appropriate",
"function",
"(",
"s",
")",
"and",
"provide",
"the",
"response",
"(",
"s",
")"
] | train | https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/router.py#L37-L57 |
Diaoul/pyextdirect | pyextdirect/router.py | Router.call | def call(self, request):
"""Call the appropriate function
:param dict request: request that describes the function to call
:return: response linked to the request that holds the value returned by the called function
:rtype: dict
"""
result = None
try:
... | python | def call(self, request):
"""Call the appropriate function
:param dict request: request that describes the function to call
:return: response linked to the request that holds the value returned by the called function
:rtype: dict
"""
result = None
try:
... | [
"def",
"call",
"(",
"self",
",",
"request",
")",
":",
"result",
"=",
"None",
"try",
":",
"if",
"'extAction'",
"in",
"request",
":",
"# DirectSubmit method",
"tid",
"=",
"request",
"[",
"'extTID'",
"]",
"action",
"=",
"request",
"[",
"'extAction'",
"]",
"... | Call the appropriate function
:param dict request: request that describes the function to call
:return: response linked to the request that holds the value returned by the called function
:rtype: dict | [
"Call",
"the",
"appropriate",
"function"
] | train | https://github.com/Diaoul/pyextdirect/blob/34ddfe882d467b3769644e8131fb90fe472eff80/pyextdirect/router.py#L59-L114 |
collectiveacuity/labPack | labpack/platforms/localhost.py | localhostClient.app_data | def app_data(self, org_name, prod_name):
''' a method to retrieve the os appropriate path to user app data
# https://www.chromium.org/user-experience/user-data-directory
:param org_name: string with name of product/service creator
:param prod_name: string with name of product/s... | python | def app_data(self, org_name, prod_name):
''' a method to retrieve the os appropriate path to user app data
# https://www.chromium.org/user-experience/user-data-directory
:param org_name: string with name of product/service creator
:param prod_name: string with name of product/s... | [
"def",
"app_data",
"(",
"self",
",",
"org_name",
",",
"prod_name",
")",
":",
"__name__",
"=",
"'%s.app_data'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs\r",
"org_name",
"=",
"self",
".",
"fields",
".",
"validate",
"(",
"org_name",
",... | a method to retrieve the os appropriate path to user app data
# https://www.chromium.org/user-experience/user-data-directory
:param org_name: string with name of product/service creator
:param prod_name: string with name of product/service
:return: string with path to app data | [
"a",
"method",
"to",
"retrieve",
"the",
"os",
"appropriate",
"path",
"to",
"user",
"app",
"data",
"#",
"https",
":",
"//",
"www",
".",
"chromium",
".",
"org",
"/",
"user",
"-",
"experience",
"/",
"user",
"-",
"data",
"-",
"directory",
":",
"param",
"... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/localhost.py#L161-L201 |
collectiveacuity/labPack | labpack/platforms/localhost.py | localhostClient.walk | def walk(self, walk_root='', reverse_order=False, previous_file=''):
''' a generator method of file paths on localhost from walk of directories
:param walk_root: string with path from which to root walk of localhost directories
:param reverse_order: boolean to determine alphabetical direc... | python | def walk(self, walk_root='', reverse_order=False, previous_file=''):
''' a generator method of file paths on localhost from walk of directories
:param walk_root: string with path from which to root walk of localhost directories
:param reverse_order: boolean to determine alphabetical direc... | [
"def",
"walk",
"(",
"self",
",",
"walk_root",
"=",
"''",
",",
"reverse_order",
"=",
"False",
",",
"previous_file",
"=",
"''",
")",
":",
"__name__",
"=",
"'%s.walk(...)'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate input\r",
"input_kwargs",
"... | a generator method of file paths on localhost from walk of directories
:param walk_root: string with path from which to root walk of localhost directories
:param reverse_order: boolean to determine alphabetical direction of walk
:param previous_file: string with path of file after which to ... | [
"a",
"generator",
"method",
"of",
"file",
"paths",
"on",
"localhost",
"from",
"walk",
"of",
"directories",
":",
"param",
"walk_root",
":",
"string",
"with",
"path",
"from",
"which",
"to",
"root",
"walk",
"of",
"localhost",
"directories",
":",
"param",
"rever... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/localhost.py#L203-L270 |
collectiveacuity/labPack | labpack/platforms/localhost.py | localhostClient.metadata | def metadata(self, file_path):
''' a method to retrieve the metadata of a file on the localhost
:param file_path: string with path to file
:return: dictionary with file properties
'''
__name__ = '%s.metadata(...)' % self.__class__.__name__
# validate input
... | python | def metadata(self, file_path):
''' a method to retrieve the metadata of a file on the localhost
:param file_path: string with path to file
:return: dictionary with file properties
'''
__name__ = '%s.metadata(...)' % self.__class__.__name__
# validate input
... | [
"def",
"metadata",
"(",
"self",
",",
"file_path",
")",
":",
"__name__",
"=",
"'%s.metadata(...)'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate input\r",
"self",
".",
"fields",
".",
"validate",
"(",
"file_path",
",",
"'.file_path'",
")",
"file_e... | a method to retrieve the metadata of a file on the localhost
:param file_path: string with path to file
:return: dictionary with file properties | [
"a",
"method",
"to",
"retrieve",
"the",
"metadata",
"of",
"a",
"file",
"on",
"the",
"localhost",
":",
"param",
"file_path",
":",
"string",
"with",
"path",
"to",
"file",
":",
"return",
":",
"dictionary",
"with",
"file",
"properties"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/localhost.py#L272-L305 |
collectiveacuity/labPack | labpack/platforms/localhost.py | localhostClient.conditional_filter | def conditional_filter(self, metadata_filters):
''' a method to construct a conditional filter function for the list method
:param metadata_filters: list with query criteria dictionaries
:return: filter_function object
NOTE: query criteria architecture
... | python | def conditional_filter(self, metadata_filters):
''' a method to construct a conditional filter function for the list method
:param metadata_filters: list with query criteria dictionaries
:return: filter_function object
NOTE: query criteria architecture
... | [
"def",
"conditional_filter",
"(",
"self",
",",
"metadata_filters",
")",
":",
"# validate input\r",
"self",
".",
"fields",
".",
"validate",
"(",
"metadata_filters",
",",
"'.metadata_filters'",
")",
"# construct function called by list function\r",
"def",
"query_function",
... | a method to construct a conditional filter function for the list method
:param metadata_filters: list with query criteria dictionaries
:return: filter_function object
NOTE: query criteria architecture
each item in the metadata filters list must be a dictionary... | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"for",
"the",
"list",
"method",
":",
"param",
"metadata_filters",
":",
"list",
"with",
"query",
"criteria",
"dictionaries",
":",
"return",
":",
"filter_function",
"object",
"NOTE",
":",
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/localhost.py#L307-L390 |
collectiveacuity/labPack | labpack/platforms/localhost.py | localhostClient.list | def list(self, filter_function=None, list_root='', max_results=1, reverse_order=False, previous_file=''):
''' a method to list files on localhost from walk of directories
:param filter_function: (keyword arguments) function used to filter results
:param list_root: string with localhost pa... | python | def list(self, filter_function=None, list_root='', max_results=1, reverse_order=False, previous_file=''):
''' a method to list files on localhost from walk of directories
:param filter_function: (keyword arguments) function used to filter results
:param list_root: string with localhost pa... | [
"def",
"list",
"(",
"self",
",",
"filter_function",
"=",
"None",
",",
"list_root",
"=",
"''",
",",
"max_results",
"=",
"1",
",",
"reverse_order",
"=",
"False",
",",
"previous_file",
"=",
"''",
")",
":",
"__name__",
"=",
"'%s.list(...)'",
"%",
"self",
"."... | a method to list files on localhost from walk of directories
:param filter_function: (keyword arguments) function used to filter results
:param list_root: string with localhost path from which to root list of files
:param max_results: integer with maximum number of results to return
... | [
"a",
"method",
"to",
"list",
"files",
"on",
"localhost",
"from",
"walk",
"of",
"directories",
":",
"param",
"filter_function",
":",
"(",
"keyword",
"arguments",
")",
"function",
"used",
"to",
"filter",
"results",
":",
"param",
"list_root",
":",
"string",
"wi... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/platforms/localhost.py#L392-L464 |
ngmiller/mipsy | mipsy/encoder.py | Encoder.encode_instruction | def encode_instruction(self, pc, instr):
"""
Given an instruction string, generate the encoded bit string.
PC (instruction index is used for branch label resolution)
"""
data = instr.split()
operation = data[0]
try:
mips_op_info = MIPS.operations[oper... | python | def encode_instruction(self, pc, instr):
"""
Given an instruction string, generate the encoded bit string.
PC (instruction index is used for branch label resolution)
"""
data = instr.split()
operation = data[0]
try:
mips_op_info = MIPS.operations[oper... | [
"def",
"encode_instruction",
"(",
"self",
",",
"pc",
",",
"instr",
")",
":",
"data",
"=",
"instr",
".",
"split",
"(",
")",
"operation",
"=",
"data",
"[",
"0",
"]",
"try",
":",
"mips_op_info",
"=",
"MIPS",
".",
"operations",
"[",
"operation",
"]",
"ex... | Given an instruction string, generate the encoded bit string.
PC (instruction index is used for branch label resolution) | [
"Given",
"an",
"instruction",
"string",
"generate",
"the",
"encoded",
"bit",
"string",
".",
"PC",
"(",
"instruction",
"index",
"is",
"used",
"for",
"branch",
"label",
"resolution",
")"
] | train | https://github.com/ngmiller/mipsy/blob/78c058f44685765193acd386e81fada3b4187b95/mipsy/encoder.py#L106-L131 |
ngmiller/mipsy | mipsy/encoder.py | Encoder.resolve_operation_info | def resolve_operation_info(self, encoding_map, mips_op_info):
"""
Adds the predefined operation info (opcode, funct) to the current encoding map.
"""
encoding_map['opcode'] = mips_op_info.opcode
encoding_map['funct'] = mips_op_info.funct | python | def resolve_operation_info(self, encoding_map, mips_op_info):
"""
Adds the predefined operation info (opcode, funct) to the current encoding map.
"""
encoding_map['opcode'] = mips_op_info.opcode
encoding_map['funct'] = mips_op_info.funct | [
"def",
"resolve_operation_info",
"(",
"self",
",",
"encoding_map",
",",
"mips_op_info",
")",
":",
"encoding_map",
"[",
"'opcode'",
"]",
"=",
"mips_op_info",
".",
"opcode",
"encoding_map",
"[",
"'funct'",
"]",
"=",
"mips_op_info",
".",
"funct"
] | Adds the predefined operation info (opcode, funct) to the current encoding map. | [
"Adds",
"the",
"predefined",
"operation",
"info",
"(",
"opcode",
"funct",
")",
"to",
"the",
"current",
"encoding",
"map",
"."
] | train | https://github.com/ngmiller/mipsy/blob/78c058f44685765193acd386e81fada3b4187b95/mipsy/encoder.py#L133-L138 |
ngmiller/mipsy | mipsy/encoder.py | Encoder.resolve_operands | def resolve_operands(self, encoding_map, operation, pc):
"""
Converts generic register references (such as $t0, $t1, etc), immediate values, and jump addresses
to their binary equivalents.
"""
convert = Encoder.to_binary
branch_replace = False
jump_replace = False... | python | def resolve_operands(self, encoding_map, operation, pc):
"""
Converts generic register references (such as $t0, $t1, etc), immediate values, and jump addresses
to their binary equivalents.
"""
convert = Encoder.to_binary
branch_replace = False
jump_replace = False... | [
"def",
"resolve_operands",
"(",
"self",
",",
"encoding_map",
",",
"operation",
",",
"pc",
")",
":",
"convert",
"=",
"Encoder",
".",
"to_binary",
"branch_replace",
"=",
"False",
"jump_replace",
"=",
"False",
"for",
"operand",
",",
"value",
"in",
"encoding_map",... | Converts generic register references (such as $t0, $t1, etc), immediate values, and jump addresses
to their binary equivalents. | [
"Converts",
"generic",
"register",
"references",
"(",
"such",
"as",
"$t0",
"$t1",
"etc",
")",
"immediate",
"values",
"and",
"jump",
"addresses",
"to",
"their",
"binary",
"equivalents",
"."
] | train | https://github.com/ngmiller/mipsy/blob/78c058f44685765193acd386e81fada3b4187b95/mipsy/encoder.py#L140-L194 |
ngmiller/mipsy | mipsy/encoder.py | Encoder.to_binary | def to_binary(decimal, length):
"""
Given a decimal, generate the binary equivalent string of
given length.
e.g. binary(2, 5) = 00010
"""
b = bitstring.Bits(int=decimal, length=length)
return b.bin | python | def to_binary(decimal, length):
"""
Given a decimal, generate the binary equivalent string of
given length.
e.g. binary(2, 5) = 00010
"""
b = bitstring.Bits(int=decimal, length=length)
return b.bin | [
"def",
"to_binary",
"(",
"decimal",
",",
"length",
")",
":",
"b",
"=",
"bitstring",
".",
"Bits",
"(",
"int",
"=",
"decimal",
",",
"length",
"=",
"length",
")",
"return",
"b",
".",
"bin"
] | Given a decimal, generate the binary equivalent string of
given length.
e.g. binary(2, 5) = 00010 | [
"Given",
"a",
"decimal",
"generate",
"the",
"binary",
"equivalent",
"string",
"of",
"given",
"length",
".",
"e",
".",
"g",
".",
"binary",
"(",
"2",
"5",
")",
"=",
"00010"
] | train | https://github.com/ngmiller/mipsy/blob/78c058f44685765193acd386e81fada3b4187b95/mipsy/encoder.py#L197-L204 |
lambdalisue/django-roughpages | src/roughpages/utils.py | url_to_filename | def url_to_filename(url):
"""
Safely translate url to relative filename
Args:
url (str): A target url string
Returns:
str
"""
# remove leading/trailing slash
if url.startswith('/'):
url = url[1:]
if url.endswith('/'):
url = url[:-1]
# remove pardir s... | python | def url_to_filename(url):
"""
Safely translate url to relative filename
Args:
url (str): A target url string
Returns:
str
"""
# remove leading/trailing slash
if url.startswith('/'):
url = url[1:]
if url.endswith('/'):
url = url[:-1]
# remove pardir s... | [
"def",
"url_to_filename",
"(",
"url",
")",
":",
"# remove leading/trailing slash",
"if",
"url",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"[",
"1",
":",
"]",
"if",
"url",
".",
"endswith",
"(",
"'/'",
")",
":",
"url",
"=",
"url",
"["... | Safely translate url to relative filename
Args:
url (str): A target url string
Returns:
str | [
"Safely",
"translate",
"url",
"to",
"relative",
"filename"
] | train | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/utils.py#L8-L27 |
lambdalisue/django-roughpages | src/roughpages/utils.py | remove_pardir_symbols | def remove_pardir_symbols(path, sep=os.sep, pardir=os.pardir):
"""
Remove relative path symobls such as '..'
Args:
path (str): A target path string
sep (str): A strint to refer path delimiter (Default: `os.sep`)
pardir (str): A string to refer parent directory (Default: `os.pardir`)... | python | def remove_pardir_symbols(path, sep=os.sep, pardir=os.pardir):
"""
Remove relative path symobls such as '..'
Args:
path (str): A target path string
sep (str): A strint to refer path delimiter (Default: `os.sep`)
pardir (str): A string to refer parent directory (Default: `os.pardir`)... | [
"def",
"remove_pardir_symbols",
"(",
"path",
",",
"sep",
"=",
"os",
".",
"sep",
",",
"pardir",
"=",
"os",
".",
"pardir",
")",
":",
"bits",
"=",
"path",
".",
"split",
"(",
"sep",
")",
"bits",
"=",
"(",
"x",
"for",
"x",
"in",
"bits",
"if",
"x",
"... | Remove relative path symobls such as '..'
Args:
path (str): A target path string
sep (str): A strint to refer path delimiter (Default: `os.sep`)
pardir (str): A string to refer parent directory (Default: `os.pardir`)
Returns:
str | [
"Remove",
"relative",
"path",
"symobls",
"such",
"as",
".."
] | train | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/utils.py#L30-L44 |
lambdalisue/django-roughpages | src/roughpages/utils.py | replace_dots_to_underscores_at_last | def replace_dots_to_underscores_at_last(path):
"""
Remove dot ('.') while a dot is treated as a special character in backends
Args:
path (str): A target path string
Returns:
str
"""
if path == '':
return path
bits = path.split('/')
bits[-1] = bits[-1].replace('.... | python | def replace_dots_to_underscores_at_last(path):
"""
Remove dot ('.') while a dot is treated as a special character in backends
Args:
path (str): A target path string
Returns:
str
"""
if path == '':
return path
bits = path.split('/')
bits[-1] = bits[-1].replace('.... | [
"def",
"replace_dots_to_underscores_at_last",
"(",
"path",
")",
":",
"if",
"path",
"==",
"''",
":",
"return",
"path",
"bits",
"=",
"path",
".",
"split",
"(",
"'/'",
")",
"bits",
"[",
"-",
"1",
"]",
"=",
"bits",
"[",
"-",
"1",
"]",
".",
"replace",
"... | Remove dot ('.') while a dot is treated as a special character in backends
Args:
path (str): A target path string
Returns:
str | [
"Remove",
"dot",
"(",
".",
")",
"while",
"a",
"dot",
"is",
"treated",
"as",
"a",
"special",
"character",
"in",
"backends"
] | train | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/utils.py#L47-L61 |
pyokagan/pyglreg | glreg.py | _load | def _load(root):
"""Load from an xml.etree.ElementTree"""
types = _load_types(root)
enums = _load_enums(root)
commands = _load_commands(root)
features = _load_features(root)
extensions = _load_extensions(root)
return Registry(None, types, enums, commands, features, extensions) | python | def _load(root):
"""Load from an xml.etree.ElementTree"""
types = _load_types(root)
enums = _load_enums(root)
commands = _load_commands(root)
features = _load_features(root)
extensions = _load_extensions(root)
return Registry(None, types, enums, commands, features, extensions) | [
"def",
"_load",
"(",
"root",
")",
":",
"types",
"=",
"_load_types",
"(",
"root",
")",
"enums",
"=",
"_load_enums",
"(",
"root",
")",
"commands",
"=",
"_load_commands",
"(",
"root",
")",
"features",
"=",
"_load_features",
"(",
"root",
")",
"extensions",
"... | Load from an xml.etree.ElementTree | [
"Load",
"from",
"an",
"xml",
".",
"etree",
".",
"ElementTree"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L616-L623 |
pyokagan/pyglreg | glreg.py | _load_types | def _load_types(root):
"""Returns {name: Type}"""
def text(t):
if t.tag == 'name':
return '{name}'
elif t.tag == 'apientry':
return '{apientry}'
out = []
if t.text:
out.append(_escape_tpl_str(t.text))
for x in t:
out.append(... | python | def _load_types(root):
"""Returns {name: Type}"""
def text(t):
if t.tag == 'name':
return '{name}'
elif t.tag == 'apientry':
return '{apientry}'
out = []
if t.text:
out.append(_escape_tpl_str(t.text))
for x in t:
out.append(... | [
"def",
"_load_types",
"(",
"root",
")",
":",
"def",
"text",
"(",
"t",
")",
":",
"if",
"t",
".",
"tag",
"==",
"'name'",
":",
"return",
"'{name}'",
"elif",
"t",
".",
"tag",
"==",
"'apientry'",
":",
"return",
"'{apientry}'",
"out",
"=",
"[",
"]",
"if"... | Returns {name: Type} | [
"Returns",
"{",
"name",
":",
"Type",
"}"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L626-L656 |
pyokagan/pyglreg | glreg.py | _load_enums | def _load_enums(root):
"""Returns {name: Enum}"""
out = collections.OrderedDict()
for elem in root.findall('enums/enum'):
name = elem.attrib['name']
value = elem.attrib['value']
comment = elem.get('comment')
out[name] = Enum(name, value, comment)
return out | python | def _load_enums(root):
"""Returns {name: Enum}"""
out = collections.OrderedDict()
for elem in root.findall('enums/enum'):
name = elem.attrib['name']
value = elem.attrib['value']
comment = elem.get('comment')
out[name] = Enum(name, value, comment)
return out | [
"def",
"_load_enums",
"(",
"root",
")",
":",
"out",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"elem",
"in",
"root",
".",
"findall",
"(",
"'enums/enum'",
")",
":",
"name",
"=",
"elem",
".",
"attrib",
"[",
"'name'",
"]",
"value",
"=",
"e... | Returns {name: Enum} | [
"Returns",
"{",
"name",
":",
"Enum",
"}"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L659-L667 |
pyokagan/pyglreg | glreg.py | _load_commands | def _load_commands(root):
"""Returns {name: Command}"""
def proto_text(t):
if t.tag == 'name':
return '{name}'
elif t.tag == 'ptype':
return '{type}'
out = []
if t.text:
out.append(_escape_tpl_str(t.text))
for x in t:
out.ap... | python | def _load_commands(root):
"""Returns {name: Command}"""
def proto_text(t):
if t.tag == 'name':
return '{name}'
elif t.tag == 'ptype':
return '{type}'
out = []
if t.text:
out.append(_escape_tpl_str(t.text))
for x in t:
out.ap... | [
"def",
"_load_commands",
"(",
"root",
")",
":",
"def",
"proto_text",
"(",
"t",
")",
":",
"if",
"t",
".",
"tag",
"==",
"'name'",
":",
"return",
"'{name}'",
"elif",
"t",
".",
"tag",
"==",
"'ptype'",
":",
"return",
"'{type}'",
"out",
"=",
"[",
"]",
"i... | Returns {name: Command} | [
"Returns",
"{",
"name",
":",
"Command",
"}"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L691-L715 |
pyokagan/pyglreg | glreg.py | _load_features | def _load_features(root):
"""Returns {name: Feature}"""
out = collections.OrderedDict()
for elem in root.findall('feature'):
name = elem.attrib['name']
api = elem.attrib['api']
number = tuple([int(x) for x in elem.attrib['number'].split('.')])
requires = [_load_require(x) for... | python | def _load_features(root):
"""Returns {name: Feature}"""
out = collections.OrderedDict()
for elem in root.findall('feature'):
name = elem.attrib['name']
api = elem.attrib['api']
number = tuple([int(x) for x in elem.attrib['number'].split('.')])
requires = [_load_require(x) for... | [
"def",
"_load_features",
"(",
"root",
")",
":",
"out",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"elem",
"in",
"root",
".",
"findall",
"(",
"'feature'",
")",
":",
"name",
"=",
"elem",
".",
"attrib",
"[",
"'name'",
"]",
"api",
"=",
"ele... | Returns {name: Feature} | [
"Returns",
"{",
"name",
":",
"Feature",
"}"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L737-L748 |
pyokagan/pyglreg | glreg.py | _load_extensions | def _load_extensions(root):
"""Returns {name: Extension}"""
out = collections.OrderedDict()
for elem in root.findall('extensions/extension'):
name = elem.attrib['name']
supported = set(elem.attrib['supported'].split('|'))
requires = [_load_require(x) for x in elem.findall('require')]... | python | def _load_extensions(root):
"""Returns {name: Extension}"""
out = collections.OrderedDict()
for elem in root.findall('extensions/extension'):
name = elem.attrib['name']
supported = set(elem.attrib['supported'].split('|'))
requires = [_load_require(x) for x in elem.findall('require')]... | [
"def",
"_load_extensions",
"(",
"root",
")",
":",
"out",
"=",
"collections",
".",
"OrderedDict",
"(",
")",
"for",
"elem",
"in",
"root",
".",
"findall",
"(",
"'extensions/extension'",
")",
":",
"name",
"=",
"elem",
".",
"attrib",
"[",
"'name'",
"]",
"supp... | Returns {name: Extension} | [
"Returns",
"{",
"name",
":",
"Extension",
"}"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L751-L760 |
pyokagan/pyglreg | glreg.py | import_type | def import_type(dest, src, name, api=None, filter_symbol=None):
"""Import Type `name` and its dependencies from Registry `src`
to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of type to import
:param str api: Prefer to im... | python | def import_type(dest, src, name, api=None, filter_symbol=None):
"""Import Type `name` and its dependencies from Registry `src`
to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of type to import
:param str api: Prefer to im... | [
"def",
"import_type",
"(",
"dest",
",",
"src",
",",
"name",
",",
"api",
"=",
"None",
",",
"filter_symbol",
"=",
"None",
")",
":",
"if",
"not",
"filter_symbol",
":",
"filter_symbol",
"=",
"_default_filter_symbol",
"type",
"=",
"src",
".",
"get_type",
"(",
... | Import Type `name` and its dependencies from Registry `src`
to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of type to import
:param str api: Prefer to import Types with api Name `api`, or None to
import T... | [
"Import",
"Type",
"name",
"and",
"its",
"dependencies",
"from",
"Registry",
"src",
"to",
"Registry",
"dest",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L794-L814 |
pyokagan/pyglreg | glreg.py | import_command | def import_command(dest, src, name, api=None, filter_symbol=None):
"""Import Command `name` and its dependencies from Registry `src`
to Registry `dest`
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Command to import
:param str api: Pref... | python | def import_command(dest, src, name, api=None, filter_symbol=None):
"""Import Command `name` and its dependencies from Registry `src`
to Registry `dest`
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Command to import
:param str api: Pref... | [
"def",
"import_command",
"(",
"dest",
",",
"src",
",",
"name",
",",
"api",
"=",
"None",
",",
"filter_symbol",
"=",
"None",
")",
":",
"if",
"not",
"filter_symbol",
":",
"filter_symbol",
"=",
"_default_filter_symbol",
"cmd",
"=",
"src",
".",
"commands",
"[",... | Import Command `name` and its dependencies from Registry `src`
to Registry `dest`
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Command to import
:param str api: Prefer to import Types with api name `api`, or None to
imp... | [
"Import",
"Command",
"name",
"and",
"its",
"dependencies",
"from",
"Registry",
"src",
"to",
"Registry",
"dest"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L817-L837 |
pyokagan/pyglreg | glreg.py | import_enum | def import_enum(dest, src, name):
"""Import Enum `name` from Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Enum to import
"""
dest.enums[name] = src.enums[name] | python | def import_enum(dest, src, name):
"""Import Enum `name` from Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Enum to import
"""
dest.enums[name] = src.enums[name] | [
"def",
"import_enum",
"(",
"dest",
",",
"src",
",",
"name",
")",
":",
"dest",
".",
"enums",
"[",
"name",
"]",
"=",
"src",
".",
"enums",
"[",
"name",
"]"
] | Import Enum `name` from Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Enum to import | [
"Import",
"Enum",
"name",
"from",
"Registry",
"src",
"to",
"Registry",
"dest",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L840-L847 |
pyokagan/pyglreg | glreg.py | import_feature | def import_feature(dest, src, name, api=None, profile=None,
filter_symbol=None):
"""Imports Feature `name`, and all its dependencies, from
Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of F... | python | def import_feature(dest, src, name, api=None, profile=None,
filter_symbol=None):
"""Imports Feature `name`, and all its dependencies, from
Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of F... | [
"def",
"import_feature",
"(",
"dest",
",",
"src",
",",
"name",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"filter_symbol",
"=",
"None",
")",
":",
"if",
"filter_symbol",
"is",
"None",
":",
"filter_symbol",
"=",
"_default_filter_symbol",
"ft"... | Imports Feature `name`, and all its dependencies, from
Registry `src` to Registry `dest`.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Feature to import
:param str api: Prefer to import dependencies with api name `api`,
... | [
"Imports",
"Feature",
"name",
"and",
"all",
"its",
"dependencies",
"from",
"Registry",
"src",
"to",
"Registry",
"dest",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L850-L890 |
pyokagan/pyglreg | glreg.py | import_extension | def import_extension(dest, src, name, api=None, profile=None,
filter_symbol=None):
"""Imports Extension `name`, and all its dependencies.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Extension to import
:param str api:... | python | def import_extension(dest, src, name, api=None, profile=None,
filter_symbol=None):
"""Imports Extension `name`, and all its dependencies.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Extension to import
:param str api:... | [
"def",
"import_extension",
"(",
"dest",
",",
"src",
",",
"name",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"filter_symbol",
"=",
"None",
")",
":",
"if",
"filter_symbol",
"is",
"None",
":",
"filter_symbol",
"=",
"_default_filter_symbol",
"e... | Imports Extension `name`, and all its dependencies.
:param Registry dest: Destination Registry
:param Registry src: Source Registry
:param str name: Name of Extension to import
:param str api: Prefer to import types with API name `api`,
or None to prefer Types with no API name.
:typ... | [
"Imports",
"Extension",
"name",
"and",
"all",
"its",
"dependencies",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L893-L923 |
pyokagan/pyglreg | glreg.py | import_registry | def import_registry(dest, src, api=None, profile=None, support=None,
filter_symbol=None):
"""Imports all features and extensions and all their dependencies.
:param Registry dest: Destination API
:param Registry src: Source Registry
:param str api: Only import Features with API name ... | python | def import_registry(dest, src, api=None, profile=None, support=None,
filter_symbol=None):
"""Imports all features and extensions and all their dependencies.
:param Registry dest: Destination API
:param Registry src: Source Registry
:param str api: Only import Features with API name ... | [
"def",
"import_registry",
"(",
"dest",
",",
"src",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"support",
"=",
"None",
",",
"filter_symbol",
"=",
"None",
")",
":",
"if",
"filter_symbol",
"is",
"None",
":",
"filter_symbol",
"=",
"_default_f... | Imports all features and extensions and all their dependencies.
:param Registry dest: Destination API
:param Registry src: Source Registry
:param str api: Only import Features with API name `api`, or None
to import all features.
:param str profile: Only import Features with profile ... | [
"Imports",
"all",
"features",
"and",
"extensions",
"and",
"all",
"their",
"dependencies",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L926-L947 |
pyokagan/pyglreg | glreg.py | extension_sort_key | def extension_sort_key(extension):
"""Returns the sorting key for an extension.
The sorting key can be used to sort a list of extensions
into the order that is used in the Khronos C OpenGL headers.
:param Extension extension: Extension to produce sort key for
:returns: A sorting key
"""
nam... | python | def extension_sort_key(extension):
"""Returns the sorting key for an extension.
The sorting key can be used to sort a list of extensions
into the order that is used in the Khronos C OpenGL headers.
:param Extension extension: Extension to produce sort key for
:returns: A sorting key
"""
nam... | [
"def",
"extension_sort_key",
"(",
"extension",
")",
":",
"name",
"=",
"extension",
".",
"name",
"category",
"=",
"name",
".",
"split",
"(",
"'_'",
",",
"2",
")",
"[",
"1",
"]",
"return",
"(",
"0",
",",
"name",
")",
"if",
"category",
"in",
"(",
"'AR... | Returns the sorting key for an extension.
The sorting key can be used to sort a list of extensions
into the order that is used in the Khronos C OpenGL headers.
:param Extension extension: Extension to produce sort key for
:returns: A sorting key | [
"Returns",
"the",
"sorting",
"key",
"for",
"an",
"extension",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L950-L960 |
pyokagan/pyglreg | glreg.py | group_apis | def group_apis(reg, features=None, extensions=None, api=None, profile=None,
support=None):
"""Groups Types, Enums, Commands with their respective Features, Extensions
Similar to :py:func:`import_registry`, but generates a new Registry object
for every feature or extension.
:param Regist... | python | def group_apis(reg, features=None, extensions=None, api=None, profile=None,
support=None):
"""Groups Types, Enums, Commands with their respective Features, Extensions
Similar to :py:func:`import_registry`, but generates a new Registry object
for every feature or extension.
:param Regist... | [
"def",
"group_apis",
"(",
"reg",
",",
"features",
"=",
"None",
",",
"extensions",
"=",
"None",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"support",
"=",
"None",
")",
":",
"features",
"=",
"(",
"reg",
".",
"get_features",
"(",
"api",
... | Groups Types, Enums, Commands with their respective Features, Extensions
Similar to :py:func:`import_registry`, but generates a new Registry object
for every feature or extension.
:param Registry reg: Input registry
:param features: Feature names to import, or None to import all.
:type features: I... | [
"Groups",
"Types",
"Enums",
"Commands",
"with",
"their",
"respective",
"Features",
"Extensions"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L963-L1009 |
pyokagan/pyglreg | glreg.py | main | def main(args=None, prog=None):
"""Generates a C header file"""
args = args if args is not None else sys.argv[1:]
prog = prog if prog is not None else sys.argv[0]
# Prevent broken pipe exception from being raised.
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
stdin = sys.stdin.buffer if hasattr(... | python | def main(args=None, prog=None):
"""Generates a C header file"""
args = args if args is not None else sys.argv[1:]
prog = prog if prog is not None else sys.argv[0]
# Prevent broken pipe exception from being raised.
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
stdin = sys.stdin.buffer if hasattr(... | [
"def",
"main",
"(",
"args",
"=",
"None",
",",
"prog",
"=",
"None",
")",
":",
"args",
"=",
"args",
"if",
"args",
"is",
"not",
"None",
"else",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"prog",
"=",
"prog",
"if",
"prog",
"is",
"not",
"None",
"else",... | Generates a C header file | [
"Generates",
"a",
"C",
"header",
"file"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L1012-L1065 |
pyokagan/pyglreg | glreg.py | Command.required_types | def required_types(self):
"""Set of names of types which the Command depends on.
"""
required_types = set(x.type for x in self.params)
required_types.add(self.type)
required_types.discard(None)
return required_types | python | def required_types(self):
"""Set of names of types which the Command depends on.
"""
required_types = set(x.type for x in self.params)
required_types.add(self.type)
required_types.discard(None)
return required_types | [
"def",
"required_types",
"(",
"self",
")",
":",
"required_types",
"=",
"set",
"(",
"x",
".",
"type",
"for",
"x",
"in",
"self",
".",
"params",
")",
"required_types",
".",
"add",
"(",
"self",
".",
"type",
")",
"required_types",
".",
"discard",
"(",
"None... | Set of names of types which the Command depends on. | [
"Set",
"of",
"names",
"of",
"types",
"which",
"the",
"Command",
"depends",
"on",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L202-L208 |
pyokagan/pyglreg | glreg.py | Command.proto_text | def proto_text(self):
"""Formatted Command identifier.
Equivalent to ``self.proto_template.format(type=self.type,
name=self.name)``.
"""
return self.proto_template.format(type=self.type, name=self.name) | python | def proto_text(self):
"""Formatted Command identifier.
Equivalent to ``self.proto_template.format(type=self.type,
name=self.name)``.
"""
return self.proto_template.format(type=self.type, name=self.name) | [
"def",
"proto_text",
"(",
"self",
")",
":",
"return",
"self",
".",
"proto_template",
".",
"format",
"(",
"type",
"=",
"self",
".",
"type",
",",
"name",
"=",
"self",
".",
"name",
")"
] | Formatted Command identifier.
Equivalent to ``self.proto_template.format(type=self.type,
name=self.name)``. | [
"Formatted",
"Command",
"identifier",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L211-L217 |
pyokagan/pyglreg | glreg.py | Command.text | def text(self):
"""Formatted Command declaration.
This is the C declaration for the command.
"""
params = ', '.join(x.text for x in self.params)
return '{0} ({1})'.format(self.proto_text, params) | python | def text(self):
"""Formatted Command declaration.
This is the C declaration for the command.
"""
params = ', '.join(x.text for x in self.params)
return '{0} ({1})'.format(self.proto_text, params) | [
"def",
"text",
"(",
"self",
")",
":",
"params",
"=",
"', '",
".",
"join",
"(",
"x",
".",
"text",
"for",
"x",
"in",
"self",
".",
"params",
")",
"return",
"'{0} ({1})'",
".",
"format",
"(",
"self",
".",
"proto_text",
",",
"params",
")"
] | Formatted Command declaration.
This is the C declaration for the command. | [
"Formatted",
"Command",
"declaration",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L220-L226 |
pyokagan/pyglreg | glreg.py | Param.text | def text(self):
"""Formatted param definition
Equivalent to ``self.template.format(name=self.name, type=self.type)``.
"""
return self.template.format(name=self.name, type=self.type) | python | def text(self):
"""Formatted param definition
Equivalent to ``self.template.format(name=self.name, type=self.type)``.
"""
return self.template.format(name=self.name, type=self.type) | [
"def",
"text",
"(",
"self",
")",
":",
"return",
"self",
".",
"template",
".",
"format",
"(",
"name",
"=",
"self",
".",
"name",
",",
"type",
"=",
"self",
".",
"type",
")"
] | Formatted param definition
Equivalent to ``self.template.format(name=self.name, type=self.type)``. | [
"Formatted",
"param",
"definition"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L243-L248 |
pyokagan/pyglreg | glreg.py | Require.as_symbols | def as_symbols(self):
"""Set of symbols required by this Require
:return: set of ``(symbol type, symbol name)`` tuples
"""
out = set()
for name in self.types:
out.add(('type', name))
for name in self.enums:
out.add(('enum', name))
for name... | python | def as_symbols(self):
"""Set of symbols required by this Require
:return: set of ``(symbol type, symbol name)`` tuples
"""
out = set()
for name in self.types:
out.add(('type', name))
for name in self.enums:
out.add(('enum', name))
for name... | [
"def",
"as_symbols",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
")",
"for",
"name",
"in",
"self",
".",
"types",
":",
"out",
".",
"add",
"(",
"(",
"'type'",
",",
"name",
")",
")",
"for",
"name",
"in",
"self",
".",
"enums",
":",
"out",
".",
... | Set of symbols required by this Require
:return: set of ``(symbol type, symbol name)`` tuples | [
"Set",
"of",
"symbols",
"required",
"by",
"this",
"Require"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L274-L286 |
pyokagan/pyglreg | glreg.py | Feature.get_profiles | def get_profiles(self):
"""Returns set of profile names referenced in this Feature
:returns: set of profile names
"""
out = set(x.profile for x in self.requires if x.profile)
out.update(x.profile for x in self.removes if x.profile)
return out | python | def get_profiles(self):
"""Returns set of profile names referenced in this Feature
:returns: set of profile names
"""
out = set(x.profile for x in self.requires if x.profile)
out.update(x.profile for x in self.removes if x.profile)
return out | [
"def",
"get_profiles",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
"x",
".",
"profile",
"for",
"x",
"in",
"self",
".",
"requires",
"if",
"x",
".",
"profile",
")",
"out",
".",
"update",
"(",
"x",
".",
"profile",
"for",
"x",
"in",
"self",
".",
... | Returns set of profile names referenced in this Feature
:returns: set of profile names | [
"Returns",
"set",
"of",
"profile",
"names",
"referenced",
"in",
"this",
"Feature"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L355-L362 |
pyokagan/pyglreg | glreg.py | Feature.get_requires | def get_requires(self, profile=None):
"""Get filtered list of Require objects in this Feature
:param str profile: Return Require objects with this profile or None
to return all Require objects.
:return: list of Require objects
"""
out = []
for... | python | def get_requires(self, profile=None):
"""Get filtered list of Require objects in this Feature
:param str profile: Return Require objects with this profile or None
to return all Require objects.
:return: list of Require objects
"""
out = []
for... | [
"def",
"get_requires",
"(",
"self",
",",
"profile",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"req",
"in",
"self",
".",
"requires",
":",
"# Filter Require by profile",
"if",
"(",
"(",
"req",
".",
"profile",
"and",
"not",
"profile",
")",
"or",... | Get filtered list of Require objects in this Feature
:param str profile: Return Require objects with this profile or None
to return all Require objects.
:return: list of Require objects | [
"Get",
"filtered",
"list",
"of",
"Require",
"objects",
"in",
"this",
"Feature"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L364-L378 |
pyokagan/pyglreg | glreg.py | Feature.get_removes | def get_removes(self, profile=None):
"""Get filtered list of Remove objects in this Feature
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
:return: list of Remove objects
"""
out = []
for rem ... | python | def get_removes(self, profile=None):
"""Get filtered list of Remove objects in this Feature
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
:return: list of Remove objects
"""
out = []
for rem ... | [
"def",
"get_removes",
"(",
"self",
",",
"profile",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"rem",
"in",
"self",
".",
"removes",
":",
"# Filter Remove by profile",
"if",
"(",
"(",
"rem",
".",
"profile",
"and",
"not",
"profile",
")",
"or",
... | Get filtered list of Remove objects in this Feature
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
:return: list of Remove objects | [
"Get",
"filtered",
"list",
"of",
"Remove",
"objects",
"in",
"this",
"Feature"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L380-L394 |
pyokagan/pyglreg | glreg.py | Extension.get_apis | def get_apis(self):
"""Returns set of api names referenced in this Extension
:return: set of api name strings
"""
out = set()
out.update(x.api for x in self.requires if x.api)
return out | python | def get_apis(self):
"""Returns set of api names referenced in this Extension
:return: set of api name strings
"""
out = set()
out.update(x.api for x in self.requires if x.api)
return out | [
"def",
"get_apis",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
")",
"out",
".",
"update",
"(",
"x",
".",
"api",
"for",
"x",
"in",
"self",
".",
"requires",
"if",
"x",
".",
"api",
")",
"return",
"out"
] | Returns set of api names referenced in this Extension
:return: set of api name strings | [
"Returns",
"set",
"of",
"api",
"names",
"referenced",
"in",
"this",
"Extension"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L416-L423 |
pyokagan/pyglreg | glreg.py | Extension.get_profiles | def get_profiles(self):
"""Returns set of profile names referenced in this Extension
:return: set of profile name strings
"""
return set(x.profile for x in self.requires if x.profile) | python | def get_profiles(self):
"""Returns set of profile names referenced in this Extension
:return: set of profile name strings
"""
return set(x.profile for x in self.requires if x.profile) | [
"def",
"get_profiles",
"(",
"self",
")",
":",
"return",
"set",
"(",
"x",
".",
"profile",
"for",
"x",
"in",
"self",
".",
"requires",
"if",
"x",
".",
"profile",
")"
] | Returns set of profile names referenced in this Extension
:return: set of profile name strings | [
"Returns",
"set",
"of",
"profile",
"names",
"referenced",
"in",
"this",
"Extension"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L425-L430 |
pyokagan/pyglreg | glreg.py | Extension.get_requires | def get_requires(self, api=None, profile=None):
"""Return filtered list of Require objects in this Extension
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with this profile or N... | python | def get_requires(self, api=None, profile=None):
"""Return filtered list of Require objects in this Extension
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with this profile or N... | [
"def",
"get_requires",
"(",
"self",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"req",
"in",
"self",
".",
"requires",
":",
"# Filter Remove by API",
"if",
"(",
"req",
".",
"api",
"and",
"not",
"api",
... | Return filtered list of Require objects in this Extension
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with this profile or None
to return all Require objec... | [
"Return",
"filtered",
"list",
"of",
"Require",
"objects",
"in",
"this",
"Extension"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L439-L458 |
pyokagan/pyglreg | glreg.py | Registry.text | def text(self):
"""Formatted API declarations.
Equivalent to the concatenation of `text` attributes of
types, enums and commands in this Registry.
"""
out = []
out.extend(x.text for x in self.types.values())
out.extend(x.text for x in self.enums.values())
... | python | def text(self):
"""Formatted API declarations.
Equivalent to the concatenation of `text` attributes of
types, enums and commands in this Registry.
"""
out = []
out.extend(x.text for x in self.types.values())
out.extend(x.text for x in self.enums.values())
... | [
"def",
"text",
"(",
"self",
")",
":",
"out",
"=",
"[",
"]",
"out",
".",
"extend",
"(",
"x",
".",
"text",
"for",
"x",
"in",
"self",
".",
"types",
".",
"values",
"(",
")",
")",
"out",
".",
"extend",
"(",
"x",
".",
"text",
"for",
"x",
"in",
"s... | Formatted API declarations.
Equivalent to the concatenation of `text` attributes of
types, enums and commands in this Registry. | [
"Formatted",
"API",
"declarations",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L486-L497 |
pyokagan/pyglreg | glreg.py | Registry.get_type | def get_type(self, name, api=None):
"""Returns Type `name`, with preference for the Type of `api`.
:param str name: Type name
:param str api: api name to prefer, of None to prefer types with no
api name
:return: Type object
"""
k = (name, api)
... | python | def get_type(self, name, api=None):
"""Returns Type `name`, with preference for the Type of `api`.
:param str name: Type name
:param str api: api name to prefer, of None to prefer types with no
api name
:return: Type object
"""
k = (name, api)
... | [
"def",
"get_type",
"(",
"self",
",",
"name",
",",
"api",
"=",
"None",
")",
":",
"k",
"=",
"(",
"name",
",",
"api",
")",
"if",
"k",
"in",
"self",
".",
"types",
":",
"return",
"self",
".",
"types",
"[",
"k",
"]",
"else",
":",
"return",
"self",
... | Returns Type `name`, with preference for the Type of `api`.
:param str name: Type name
:param str api: api name to prefer, of None to prefer types with no
api name
:return: Type object | [
"Returns",
"Type",
"name",
"with",
"preference",
"for",
"the",
"Type",
"of",
"api",
"."
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L499-L511 |
pyokagan/pyglreg | glreg.py | Registry.get_features | def get_features(self, api=None):
"""Returns filtered list of features in this registry
:param str api: Return only features with this api name, or None to
return all features.
:return: list of Feature objects
"""
return [x for x in self.features.values()... | python | def get_features(self, api=None):
"""Returns filtered list of features in this registry
:param str api: Return only features with this api name, or None to
return all features.
:return: list of Feature objects
"""
return [x for x in self.features.values()... | [
"def",
"get_features",
"(",
"self",
",",
"api",
"=",
"None",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"features",
".",
"values",
"(",
")",
"if",
"api",
"and",
"x",
".",
"api",
"==",
"api",
"or",
"not",
"api",
"]"
] | Returns filtered list of features in this registry
:param str api: Return only features with this api name, or None to
return all features.
:return: list of Feature objects | [
"Returns",
"filtered",
"list",
"of",
"features",
"in",
"this",
"registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L513-L521 |
pyokagan/pyglreg | glreg.py | Registry.get_extensions | def get_extensions(self, support=None):
"""Returns filtered list of extensions in this registry
:param support: Return only extensions with this extension support
string, or None to return all extensions.
:return: list of Extension objects
"""
return [x f... | python | def get_extensions(self, support=None):
"""Returns filtered list of extensions in this registry
:param support: Return only extensions with this extension support
string, or None to return all extensions.
:return: list of Extension objects
"""
return [x f... | [
"def",
"get_extensions",
"(",
"self",
",",
"support",
"=",
"None",
")",
":",
"return",
"[",
"x",
"for",
"x",
"in",
"self",
".",
"extensions",
".",
"values",
"(",
")",
"if",
"support",
"and",
"support",
"in",
"x",
".",
"supported",
"or",
"not",
"suppo... | Returns filtered list of extensions in this registry
:param support: Return only extensions with this extension support
string, or None to return all extensions.
:return: list of Extension objects | [
"Returns",
"filtered",
"list",
"of",
"extensions",
"in",
"this",
"registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L523-L531 |
pyokagan/pyglreg | glreg.py | Registry.get_requires | def get_requires(self, api=None, profile=None, support=None):
"""Returns filtered list of Require objects in this registry
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with thi... | python | def get_requires(self, api=None, profile=None, support=None):
"""Returns filtered list of Require objects in this registry
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with thi... | [
"def",
"get_requires",
"(",
"self",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"support",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"ft",
"in",
"self",
".",
"get_features",
"(",
"api",
")",
":",
"out",
".",
"extend",
"("... | Returns filtered list of Require objects in this registry
:param str api: Return Require objects with this api name or None to
return all Require objects.
:param str profile: Return Require objects with this profile or None
to return all Require objec... | [
"Returns",
"filtered",
"list",
"of",
"Require",
"objects",
"in",
"this",
"registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L533-L552 |
pyokagan/pyglreg | glreg.py | Registry.get_removes | def get_removes(self, api=None, profile=None):
"""Returns filtered list of Remove objects in this registry
:param str api: Return Remove objects with this api name or None to
return all Remove objects.
:param str profile: Return Remove objects with this profile or None
... | python | def get_removes(self, api=None, profile=None):
"""Returns filtered list of Remove objects in this registry
:param str api: Return Remove objects with this api name or None to
return all Remove objects.
:param str profile: Return Remove objects with this profile or None
... | [
"def",
"get_removes",
"(",
"self",
",",
"api",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"out",
"=",
"[",
"]",
"for",
"ft",
"in",
"self",
".",
"get_features",
"(",
"api",
")",
":",
"out",
".",
"extend",
"(",
"ft",
".",
"get_removes",
"(... | Returns filtered list of Remove objects in this registry
:param str api: Return Remove objects with this api name or None to
return all Remove objects.
:param str profile: Return Remove objects with this profile or None
to return all Remove objects.
... | [
"Returns",
"filtered",
"list",
"of",
"Remove",
"objects",
"in",
"this",
"registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L554-L566 |
pyokagan/pyglreg | glreg.py | Registry.get_apis | def get_apis(self):
"""Returns set of api names referenced in this Registry
:return: set of api name strings
"""
out = set(x.api for x in self.types.values() if x.api)
for ft in self.features.values():
out.update(ft.get_apis())
for ext in self.extensions.valu... | python | def get_apis(self):
"""Returns set of api names referenced in this Registry
:return: set of api name strings
"""
out = set(x.api for x in self.types.values() if x.api)
for ft in self.features.values():
out.update(ft.get_apis())
for ext in self.extensions.valu... | [
"def",
"get_apis",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
"x",
".",
"api",
"for",
"x",
"in",
"self",
".",
"types",
".",
"values",
"(",
")",
"if",
"x",
".",
"api",
")",
"for",
"ft",
"in",
"self",
".",
"features",
".",
"values",
"(",
")... | Returns set of api names referenced in this Registry
:return: set of api name strings | [
"Returns",
"set",
"of",
"api",
"names",
"referenced",
"in",
"this",
"Registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L568-L578 |
pyokagan/pyglreg | glreg.py | Registry.get_profiles | def get_profiles(self):
"""Returns set of profile names referenced in this Registry
:return: set of profile name strings
"""
out = set()
for ft in self.features.values():
out.update(ft.get_profiles())
for ext in self.extensions.values():
out.updat... | python | def get_profiles(self):
"""Returns set of profile names referenced in this Registry
:return: set of profile name strings
"""
out = set()
for ft in self.features.values():
out.update(ft.get_profiles())
for ext in self.extensions.values():
out.updat... | [
"def",
"get_profiles",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
")",
"for",
"ft",
"in",
"self",
".",
"features",
".",
"values",
"(",
")",
":",
"out",
".",
"update",
"(",
"ft",
".",
"get_profiles",
"(",
")",
")",
"for",
"ext",
"in",
"self",
... | Returns set of profile names referenced in this Registry
:return: set of profile name strings | [
"Returns",
"set",
"of",
"profile",
"names",
"referenced",
"in",
"this",
"Registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L580-L590 |
pyokagan/pyglreg | glreg.py | Registry.get_supports | def get_supports(self):
"""Returns set of extension support strings referenced in this Registry
:return: set of extension support strings
"""
out = set()
for ext in self.extensions.values():
out.update(ext.get_supports())
return out | python | def get_supports(self):
"""Returns set of extension support strings referenced in this Registry
:return: set of extension support strings
"""
out = set()
for ext in self.extensions.values():
out.update(ext.get_supports())
return out | [
"def",
"get_supports",
"(",
"self",
")",
":",
"out",
"=",
"set",
"(",
")",
"for",
"ext",
"in",
"self",
".",
"extensions",
".",
"values",
"(",
")",
":",
"out",
".",
"update",
"(",
"ext",
".",
"get_supports",
"(",
")",
")",
"return",
"out"
] | Returns set of extension support strings referenced in this Registry
:return: set of extension support strings | [
"Returns",
"set",
"of",
"extension",
"support",
"strings",
"referenced",
"in",
"this",
"Registry"
] | train | https://github.com/pyokagan/pyglreg/blob/68fa5a6c6cee8667879840fbbcc7d30f52852915/glreg.py#L592-L600 |
maxfischer2781/include | include/files/import_hook.py | FilePathLoader.load_module | def load_module(self, name):
"""
Load and return a module
Always returns the corresponding module. If the module is already
loaded, the existing module is returned.
"""
if name in sys.modules:
return sys.modules[name]
path = self.module2uri(name)
... | python | def load_module(self, name):
"""
Load and return a module
Always returns the corresponding module. If the module is already
loaded, the existing module is returned.
"""
if name in sys.modules:
return sys.modules[name]
path = self.module2uri(name)
... | [
"def",
"load_module",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"sys",
".",
"modules",
":",
"return",
"sys",
".",
"modules",
"[",
"name",
"]",
"path",
"=",
"self",
".",
"module2uri",
"(",
"name",
")",
"if",
"os",
".",
"path",
".",
"... | Load and return a module
Always returns the corresponding module. If the module is already
loaded, the existing module is returned. | [
"Load",
"and",
"return",
"a",
"module"
] | train | https://github.com/maxfischer2781/include/blob/d8b0404f4996b6abcd39fdebf282b31fad8bb6f5/include/files/import_hook.py#L15-L30 |
evfredericksen/pynacea | pynhost/pynhost/platforms/linux.py | get_open_window_names | def get_open_window_names():
'''
Return a dict with open program names and their corresponding decimal ids
'''
raw_names = subprocess.check_output(['wmctrl', '-l']).decode('utf8').split('\n')
split_names = [name.split() for name in raw_names if name]
name_dict = {}
for name in split_names:
... | python | def get_open_window_names():
'''
Return a dict with open program names and their corresponding decimal ids
'''
raw_names = subprocess.check_output(['wmctrl', '-l']).decode('utf8').split('\n')
split_names = [name.split() for name in raw_names if name]
name_dict = {}
for name in split_names:
... | [
"def",
"get_open_window_names",
"(",
")",
":",
"raw_names",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'wmctrl'",
",",
"'-l'",
"]",
")",
".",
"decode",
"(",
"'utf8'",
")",
".",
"split",
"(",
"'\\n'",
")",
"split_names",
"=",
"[",
"name",
".",
"... | Return a dict with open program names and their corresponding decimal ids | [
"Return",
"a",
"dict",
"with",
"open",
"program",
"names",
"and",
"their",
"corresponding",
"decimal",
"ids"
] | train | https://github.com/evfredericksen/pynacea/blob/63ee0e6695209048bf2571aa2c3770f502e29b0a/pynhost/pynhost/platforms/linux.py#L62-L72 |
pudo-attic/loadkit | loadkit/operators/table.py | resource_row_set | def resource_row_set(package, resource):
""" Generate an iterator over all the rows in this resource's
source data. """
# This is a work-around because messytables hangs on boto file
# handles, so we're doing it via plain old HTTP.
table_set = any_tableset(resource.fh(),
... | python | def resource_row_set(package, resource):
""" Generate an iterator over all the rows in this resource's
source data. """
# This is a work-around because messytables hangs on boto file
# handles, so we're doing it via plain old HTTP.
table_set = any_tableset(resource.fh(),
... | [
"def",
"resource_row_set",
"(",
"package",
",",
"resource",
")",
":",
"# This is a work-around because messytables hangs on boto file",
"# handles, so we're doing it via plain old HTTP.",
"table_set",
"=",
"any_tableset",
"(",
"resource",
".",
"fh",
"(",
")",
",",
"extension"... | Generate an iterator over all the rows in this resource's
source data. | [
"Generate",
"an",
"iterator",
"over",
"all",
"the",
"rows",
"in",
"this",
"resource",
"s",
"source",
"data",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/operators/table.py#L18-L37 |
pudo-attic/loadkit | loadkit/operators/table.py | column_alias | def column_alias(cell, names):
""" Generate a normalized version of the column name. """
column = slugify(cell.column or '', sep='_')
column = column.strip('_')
column = 'column' if not len(column) else column
name, i = column, 2
# de-dupe: column, column_2, column_3, ...
while name in names... | python | def column_alias(cell, names):
""" Generate a normalized version of the column name. """
column = slugify(cell.column or '', sep='_')
column = column.strip('_')
column = 'column' if not len(column) else column
name, i = column, 2
# de-dupe: column, column_2, column_3, ...
while name in names... | [
"def",
"column_alias",
"(",
"cell",
",",
"names",
")",
":",
"column",
"=",
"slugify",
"(",
"cell",
".",
"column",
"or",
"''",
",",
"sep",
"=",
"'_'",
")",
"column",
"=",
"column",
".",
"strip",
"(",
"'_'",
")",
"column",
"=",
"'column'",
"if",
"not... | Generate a normalized version of the column name. | [
"Generate",
"a",
"normalized",
"version",
"of",
"the",
"column",
"name",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/operators/table.py#L40-L50 |
pudo-attic/loadkit | loadkit/operators/table.py | generate_field_spec | def generate_field_spec(row):
""" Generate a set of metadata for each field/column in
the data. This is loosely based on jsontableschema. """
names = set()
fields = []
for cell in row:
name = column_alias(cell, names)
field = {
'name': name,
'title': cell.colu... | python | def generate_field_spec(row):
""" Generate a set of metadata for each field/column in
the data. This is loosely based on jsontableschema. """
names = set()
fields = []
for cell in row:
name = column_alias(cell, names)
field = {
'name': name,
'title': cell.colu... | [
"def",
"generate_field_spec",
"(",
"row",
")",
":",
"names",
"=",
"set",
"(",
")",
"fields",
"=",
"[",
"]",
"for",
"cell",
"in",
"row",
":",
"name",
"=",
"column_alias",
"(",
"cell",
",",
"names",
")",
"field",
"=",
"{",
"'name'",
":",
"name",
",",... | Generate a set of metadata for each field/column in
the data. This is loosely based on jsontableschema. | [
"Generate",
"a",
"set",
"of",
"metadata",
"for",
"each",
"field",
"/",
"column",
"in",
"the",
"data",
".",
"This",
"is",
"loosely",
"based",
"on",
"jsontableschema",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/operators/table.py#L53-L72 |
pudo-attic/loadkit | loadkit/operators/table.py | random_sample | def random_sample(value, field, row, num=10):
""" Collect a random sample of the values in a particular
field based on the reservoir sampling technique. """
# TODO: Could become a more general DQ piece.
if value is None:
field['has_nulls'] = True
return
if value in field['samples']:
... | python | def random_sample(value, field, row, num=10):
""" Collect a random sample of the values in a particular
field based on the reservoir sampling technique. """
# TODO: Could become a more general DQ piece.
if value is None:
field['has_nulls'] = True
return
if value in field['samples']:
... | [
"def",
"random_sample",
"(",
"value",
",",
"field",
",",
"row",
",",
"num",
"=",
"10",
")",
":",
"# TODO: Could become a more general DQ piece.",
"if",
"value",
"is",
"None",
":",
"field",
"[",
"'has_nulls'",
"]",
"=",
"True",
"return",
"if",
"value",
"in",
... | Collect a random sample of the values in a particular
field based on the reservoir sampling technique. | [
"Collect",
"a",
"random",
"sample",
"of",
"the",
"values",
"in",
"a",
"particular",
"field",
"based",
"on",
"the",
"reservoir",
"sampling",
"technique",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/operators/table.py#L75-L92 |
jic-dtool/dtool-config | dtool_config/cli.py | name | def name(username):
"""Display / set / update the user name."""
if not username:
click.secho(dtool_config.utils.get_username(CONFIG_PATH))
else:
username_str = " ".join(username)
click.secho(dtool_config.utils.set_username(CONFIG_PATH, username_str)) | python | def name(username):
"""Display / set / update the user name."""
if not username:
click.secho(dtool_config.utils.get_username(CONFIG_PATH))
else:
username_str = " ".join(username)
click.secho(dtool_config.utils.set_username(CONFIG_PATH, username_str)) | [
"def",
"name",
"(",
"username",
")",
":",
"if",
"not",
"username",
":",
"click",
".",
"secho",
"(",
"dtool_config",
".",
"utils",
".",
"get_username",
"(",
"CONFIG_PATH",
")",
")",
"else",
":",
"username_str",
"=",
"\" \"",
".",
"join",
"(",
"username",
... | Display / set / update the user name. | [
"Display",
"/",
"set",
"/",
"update",
"the",
"user",
"name",
"."
] | train | https://github.com/jic-dtool/dtool-config/blob/21afa99a6794909e1d0180a45895492b4b726a51/dtool_config/cli.py#L25-L31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.