repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
Capitains/MyCapytain
MyCapytain/resources/texts/remote/cts.py
CtsPassage.siblingsId
def siblingsId(self): """ Shortcut for getting the previous and next passage identifier :rtype: CtsReference :returns: Following passage reference """ if self._next_id is False or self._prev_id is False: self._prev_id, self._next_id = self.getPrevNextUrn(reference=se...
python
def siblingsId(self): """ Shortcut for getting the previous and next passage identifier :rtype: CtsReference :returns: Following passage reference """ if self._next_id is False or self._prev_id is False: self._prev_id, self._next_id = self.getPrevNextUrn(reference=se...
[ "def", "siblingsId", "(", "self", ")", ":", "if", "self", ".", "_next_id", "is", "False", "or", "self", ".", "_prev_id", "is", "False", ":", "self", ".", "_prev_id", ",", "self", ".", "_next_id", "=", "self", ".", "getPrevNextUrn", "(", "reference", "=...
Shortcut for getting the previous and next passage identifier :rtype: CtsReference :returns: Following passage reference
[ "Shortcut", "for", "getting", "the", "previous", "and", "next", "passage", "identifier" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/remote/cts.py#L443-L451
train
Shortcut for getting the previous and next passage identifier
Capitains/MyCapytain
MyCapytain/resources/texts/remote/cts.py
CtsPassage._parse
def _parse(self): """ Given self.resource, split information from the CTS API :return: None """ self.response = self.resource self.resource = self.resource.xpath("//ti:passage/tei:TEI", namespaces=XPATH_NAMESPACES)[0] self._prev_id, self._next_id = _SharedMethod.prevnex...
python
def _parse(self): """ Given self.resource, split information from the CTS API :return: None """ self.response = self.resource self.resource = self.resource.xpath("//ti:passage/tei:TEI", namespaces=XPATH_NAMESPACES)[0] self._prev_id, self._next_id = _SharedMethod.prevnex...
[ "def", "_parse", "(", "self", ")", ":", "self", ".", "response", "=", "self", ".", "resource", "self", ".", "resource", "=", "self", ".", "resource", ".", "xpath", "(", "\"//ti:passage/tei:TEI\"", ",", "namespaces", "=", "XPATH_NAMESPACES", ")", "[", "0", ...
Given self.resource, split information from the CTS API :return: None
[ "Given", "self", ".", "resource", "split", "information", "from", "the", "CTS", "API" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/texts/remote/cts.py#L453-L467
train
Given self. resource split information from the CTS API
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.get_user_token
def get_user_token(self): """ Gets a authorization token for session reuse. http://docs.exosite.com/portals/#get-user-token-for-openid-user """ headers = { 'User-Agent': self.user_agent(), 'Host': self.domain(), 'Accept': '*/*', } ...
python
def get_user_token(self): """ Gets a authorization token for session reuse. http://docs.exosite.com/portals/#get-user-token-for-openid-user """ headers = { 'User-Agent': self.user_agent(), 'Host': self.domain(), 'Accept': '*/*', } ...
[ "def", "get_user_token", "(", "self", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", "(", ")", ",", "'Host'", ":", "self", ".", "domain", "(", ")", ",", "'Accept'", ":", "'*/*'", ",", "}", "headers", ".", "update", "("...
Gets a authorization token for session reuse. http://docs.exosite.com/portals/#get-user-token-for-openid-user
[ "Gets", "a", "authorization", "token", "for", "session", "reuse", "." ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L125-L144
train
Gets a user s authorization token for session reuse.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.add_device
def add_device(self, model, serial): """ Returns 'device object' of newly created device. http://docs.exosite.com/portals/#create-device http://docs.exosite.com/portals/#device-object """ device = { 'model': model, 'vendor': se...
python
def add_device(self, model, serial): """ Returns 'device object' of newly created device. http://docs.exosite.com/portals/#create-device http://docs.exosite.com/portals/#device-object """ device = { 'model': model, 'vendor': se...
[ "def", "add_device", "(", "self", ",", "model", ",", "serial", ")", ":", "device", "=", "{", "'model'", ":", "model", ",", "'vendor'", ":", "self", ".", "vendor", "(", ")", ",", "'sn'", ":", "serial", ",", "'type'", ":", "'vendor'", "}", "headers", ...
Returns 'device object' of newly created device. http://docs.exosite.com/portals/#create-device http://docs.exosite.com/portals/#device-object
[ "Returns", "device", "object", "of", "newly", "created", "device", "." ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L212-L242
train
Adds a new device to the system.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.update_device
def update_device(self, device_obj): """ Implements the Update device Portals API. http://docs.exosite.com/portals/#update-device """ rid = device_obj['rid'] device_obj['info']['description']['meta'] = \ json.dumps(device_obj['info']['description'...
python
def update_device(self, device_obj): """ Implements the Update device Portals API. http://docs.exosite.com/portals/#update-device """ rid = device_obj['rid'] device_obj['info']['description']['meta'] = \ json.dumps(device_obj['info']['description'...
[ "def", "update_device", "(", "self", ",", "device_obj", ")", ":", "rid", "=", "device_obj", "[", "'rid'", "]", "device_obj", "[", "'info'", "]", "[", "'description'", "]", "[", "'meta'", "]", "=", "json", ".", "dumps", "(", "device_obj", "[", "'info'", ...
Implements the Update device Portals API. http://docs.exosite.com/portals/#update-device
[ "Implements", "the", "Update", "device", "Portals", "API", ".", "http", ":", "//", "docs", ".", "exosite", ".", "com", "/", "portals", "/", "#update", "-", "device" ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L244-L270
train
Implements the Update device Portals API. is used to update the related object of a specific device.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.update_portal
def update_portal(self, portal_obj): """ Implements the Update device Portals API. This function is extremely dangerous. The portal object you pass in will completely overwrite the portal. http://docs.exosite.com/portals/#update-portal """ header...
python
def update_portal(self, portal_obj): """ Implements the Update device Portals API. This function is extremely dangerous. The portal object you pass in will completely overwrite the portal. http://docs.exosite.com/portals/#update-portal """ header...
[ "def", "update_portal", "(", "self", ",", "portal_obj", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", "(", ")", ",", "}", "headers", ".", "update", "(", "self", ".", "headers", "(", ")", ")", "r", "=", "requests", "."...
Implements the Update device Portals API. This function is extremely dangerous. The portal object you pass in will completely overwrite the portal. http://docs.exosite.com/portals/#update-portal
[ "Implements", "the", "Update", "device", "Portals", "API", "." ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L272-L294
train
Implements the Update device Portals API.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.get_device
def get_device(self, rid): """ Retrieve the device object for a given RID. http://docs.exosite.com/portals/#get-device """ headers = { 'User-Agent': self.user_agent(), 'Content-Type': self.content_type() } headers.update(se...
python
def get_device(self, rid): """ Retrieve the device object for a given RID. http://docs.exosite.com/portals/#get-device """ headers = { 'User-Agent': self.user_agent(), 'Content-Type': self.content_type() } headers.update(se...
[ "def", "get_device", "(", "self", ",", "rid", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", "(", ")", ",", "'Content-Type'", ":", "self", ".", "content_type", "(", ")", "}", "headers", ".", "update", "(", "self", ".", ...
Retrieve the device object for a given RID. http://docs.exosite.com/portals/#get-device
[ "Retrieve", "the", "device", "object", "for", "a", "given", "RID", "." ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L296-L324
train
Retrieve the device object for a given RID.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.get_multiple_devices
def get_multiple_devices(self, rids): """ Implements the 'Get Multiple Devices' API. Param rids: a python list object of device rids. http://docs.exosite.com/portals/#get-multiple-devices """ headers = { 'User-Agent': self.user_agent(), ...
python
def get_multiple_devices(self, rids): """ Implements the 'Get Multiple Devices' API. Param rids: a python list object of device rids. http://docs.exosite.com/portals/#get-multiple-devices """ headers = { 'User-Agent': self.user_agent(), ...
[ "def", "get_multiple_devices", "(", "self", ",", "rids", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", "(", ")", ",", "'Content-Type'", ":", "self", ".", "content_type", "(", ")", "}", "headers", ".", "update", "(", "self...
Implements the 'Get Multiple Devices' API. Param rids: a python list object of device rids. http://docs.exosite.com/portals/#get-multiple-devices
[ "Implements", "the", "Get", "Multiple", "Devices", "API", "." ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L326-L352
train
Implements the Get Multiple Devices API.
exosite-labs/pyonep
pyonep/portals/endpoints.py
Endpoints.create_token
def create_token(self, user_id, permission_obj): """ 'permission_obj' param should be a string. e.g. '[{"access":"d_u_list","oid":{"id":"1576946496","type":"Domain"}}]' http://docs.exosite.com/portals/#add-user-permission """ headers = { 'User-Agent': s...
python
def create_token(self, user_id, permission_obj): """ 'permission_obj' param should be a string. e.g. '[{"access":"d_u_list","oid":{"id":"1576946496","type":"Domain"}}]' http://docs.exosite.com/portals/#add-user-permission """ headers = { 'User-Agent': s...
[ "def", "create_token", "(", "self", ",", "user_id", ",", "permission_obj", ")", ":", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", "(", ")", ",", "'Content-Type'", ":", "self", ".", "content_type", "(", ")", "}", "headers", ".", "u...
'permission_obj' param should be a string. e.g. '[{"access":"d_u_list","oid":{"id":"1576946496","type":"Domain"}}]' http://docs.exosite.com/portals/#add-user-permission
[ "permission_obj", "param", "should", "be", "a", "string", ".", "e", ".", "g", ".", "[", "{", "access", ":", "d_u_list", "oid", ":", "{", "id", ":", "1576946496", "type", ":", "Domain", "}}", "]" ]
d27b621b00688a542e0adcc01f3e3354c05238a1
https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/endpoints.py#L430-L455
train
Creates a new token for a user.
SHDShim/pytheos
pytheos/eqn_therm_Dorogokupets2015.py
dorogokupets2015_pth
def dorogokupets2015_pth(v, temp, v0, gamma0, gamma_inf, beta, theta01, m1, theta02, m2, n, z, t_ref=300., three_r=3. * constants.R): """ calculate thermal pressure for Dorogokupets 2015 EOS :param v: unit-cell volume in A^3 :param temp: temperature in ...
python
def dorogokupets2015_pth(v, temp, v0, gamma0, gamma_inf, beta, theta01, m1, theta02, m2, n, z, t_ref=300., three_r=3. * constants.R): """ calculate thermal pressure for Dorogokupets 2015 EOS :param v: unit-cell volume in A^3 :param temp: temperature in ...
[ "def", "dorogokupets2015_pth", "(", "v", ",", "temp", ",", "v0", ",", "gamma0", ",", "gamma_inf", ",", "beta", ",", "theta01", ",", "m1", ",", "theta02", ",", "m2", ",", "n", ",", "z", ",", "t_ref", "=", "300.", ",", "three_r", "=", "3.", "*", "c...
calculate thermal pressure for Dorogokupets 2015 EOS :param v: unit-cell volume in A^3 :param temp: temperature in K :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param gamma_inf: Gruneisen parameter at infinite pressure :param beta: volume dependence ...
[ "calculate", "thermal", "pressure", "for", "Dorogokupets", "2015", "EOS" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Dorogokupets2015.py#L9-L59
train
calculate thermal pressure for Dorogokupets 2015
Capitains/MyCapytain
MyCapytain/retrievers/dts/__init__.py
HttpDtsRetriever.call
def call(self, route, parameters, mimetype="application/ld+json", defaults=None): """ Call an endpoint given the parameters :param route: Named of the route which is called :type route: str :param parameters: Dictionary of parameters :type parameters: dict :param mimetyp...
python
def call(self, route, parameters, mimetype="application/ld+json", defaults=None): """ Call an endpoint given the parameters :param route: Named of the route which is called :type route: str :param parameters: Dictionary of parameters :type parameters: dict :param mimetyp...
[ "def", "call", "(", "self", ",", "route", ",", "parameters", ",", "mimetype", "=", "\"application/ld+json\"", ",", "defaults", "=", "None", ")", ":", "if", "not", "defaults", ":", "defaults", "=", "{", "}", "parameters", "=", "{", "key", ":", "str", "(...
Call an endpoint given the parameters :param route: Named of the route which is called :type route: str :param parameters: Dictionary of parameters :type parameters: dict :param mimetype: Mimetype to require :type mimetype: str :rtype: text
[ "Call", "an", "endpoint", "given", "the", "parameters" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/dts/__init__.py#L37-L73
train
Call an endpoint given the parameters
Capitains/MyCapytain
MyCapytain/retrievers/dts/__init__.py
HttpDtsRetriever.routes
def routes(self): """ Retrieves the main routes of the DTS Collection Response format expected : { "@context": "/dts/api/contexts/EntryPoint.jsonld", "@id": "/dts/api/", "@type": "EntryPoint", "collections": "/dts/api/collections/", ...
python
def routes(self): """ Retrieves the main routes of the DTS Collection Response format expected : { "@context": "/dts/api/contexts/EntryPoint.jsonld", "@id": "/dts/api/", "@type": "EntryPoint", "collections": "/dts/api/collections/", ...
[ "def", "routes", "(", "self", ")", ":", "if", "self", ".", "_routes", ":", "return", "self", ".", "_routes", "request", "=", "requests", ".", "get", "(", "self", ".", "endpoint", ")", "request", ".", "raise_for_status", "(", ")", "data", "=", "request"...
Retrieves the main routes of the DTS Collection Response format expected : { "@context": "/dts/api/contexts/EntryPoint.jsonld", "@id": "/dts/api/", "@type": "EntryPoint", "collections": "/dts/api/collections/", "documents": "/dts...
[ "Retrieves", "the", "main", "routes", "of", "the", "DTS", "Collection" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/dts/__init__.py#L76-L103
train
Retrieves the main routes of the DTS Collection
Capitains/MyCapytain
MyCapytain/retrievers/dts/__init__.py
HttpDtsRetriever.get_collection
def get_collection(self, collection_id=None, nav="children", page=None): """ Makes a call on the Collection API :param collection_id: Id of the collection to retrieve :param nav: Direction of the navigation :param page: Page to retrieve :return: Response :rtype: requests...
python
def get_collection(self, collection_id=None, nav="children", page=None): """ Makes a call on the Collection API :param collection_id: Id of the collection to retrieve :param nav: Direction of the navigation :param page: Page to retrieve :return: Response :rtype: requests...
[ "def", "get_collection", "(", "self", ",", "collection_id", "=", "None", ",", "nav", "=", "\"children\"", ",", "page", "=", "None", ")", ":", "return", "self", ".", "call", "(", "\"collections\"", ",", "{", "\"id\"", ":", "collection_id", ",", "\"nav\"", ...
Makes a call on the Collection API :param collection_id: Id of the collection to retrieve :param nav: Direction of the navigation :param page: Page to retrieve :return: Response :rtype: requests.Response
[ "Makes", "a", "call", "on", "the", "Collection", "API" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/dts/__init__.py#L105-L126
train
Makes a call to the API API.
Capitains/MyCapytain
MyCapytain/retrievers/dts/__init__.py
HttpDtsRetriever.get_navigation
def get_navigation( self, collection_id, level=None, ref=None, group_by=None, max_=None, exclude=None, page=None): """ Make a navigation request on the DTS API :param collection_id: Id of the collection :param level: Lever at which the references should be listed ...
python
def get_navigation( self, collection_id, level=None, ref=None, group_by=None, max_=None, exclude=None, page=None): """ Make a navigation request on the DTS API :param collection_id: Id of the collection :param level: Lever at which the references should be listed ...
[ "def", "get_navigation", "(", "self", ",", "collection_id", ",", "level", "=", "None", ",", "ref", "=", "None", ",", "group_by", "=", "None", ",", "max_", "=", "None", ",", "exclude", "=", "None", ",", "page", "=", "None", ")", ":", "parameters", "="...
Make a navigation request on the DTS API :param collection_id: Id of the collection :param level: Lever at which the references should be listed :param ref: If ref is a tuple, it is treated as a range. String or int are treated as single ref :param group_by: Size of the ranges the serve...
[ "Make", "a", "navigation", "request", "on", "the", "DTS", "API" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/dts/__init__.py#L128-L156
train
Make a navigation request on the DTS API.
Capitains/MyCapytain
MyCapytain/retrievers/dts/__init__.py
HttpDtsRetriever.get_document
def get_document( self, collection_id, ref=None, mimetype="application/tei+xml, application/xml"): """ Make a navigation request on the DTS API :param collection_id: Id of the collection :param ref: If ref is a tuple, it is treated as a range. String or int are treated a...
python
def get_document( self, collection_id, ref=None, mimetype="application/tei+xml, application/xml"): """ Make a navigation request on the DTS API :param collection_id: Id of the collection :param ref: If ref is a tuple, it is treated as a range. String or int are treated a...
[ "def", "get_document", "(", "self", ",", "collection_id", ",", "ref", "=", "None", ",", "mimetype", "=", "\"application/tei+xml, application/xml\"", ")", ":", "parameters", "=", "{", "\"id\"", ":", "collection_id", "}", "_parse_ref_parameters", "(", "parameters", ...
Make a navigation request on the DTS API :param collection_id: Id of the collection :param ref: If ref is a tuple, it is treated as a range. String or int are treated as single ref :param mimetype: Media type to request :return: Response :rtype: requests.Response
[ "Make", "a", "navigation", "request", "on", "the", "DTS", "API" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/retrievers/dts/__init__.py#L158-L178
train
Make a navigation request on the DTS API.
jiasir/playback
playback/glance.py
Glance._create_glance_db
def _create_glance_db(self, root_db_pass, glance_db_pass): """Create the glance database""" print red(env.host_string + ' | Create glance database') sudo( "mysql -uroot -p{0} -e \"CREATE DATABASE glance;\"".format(root_db_pass), shell=False) sudo("mysql -uroot -p{0} -e \...
python
def _create_glance_db(self, root_db_pass, glance_db_pass): """Create the glance database""" print red(env.host_string + ' | Create glance database') sudo( "mysql -uroot -p{0} -e \"CREATE DATABASE glance;\"".format(root_db_pass), shell=False) sudo("mysql -uroot -p{0} -e \...
[ "def", "_create_glance_db", "(", "self", ",", "root_db_pass", ",", "glance_db_pass", ")", ":", "print", "red", "(", "env", ".", "host_string", "+", "' | Create glance database'", ")", "sudo", "(", "\"mysql -uroot -p{0} -e \\\"CREATE DATABASE glance;\\\"\"", ".", "format...
Create the glance database
[ "Create", "the", "glance", "database" ]
58b2a5d669dcfaa8cad50c544a4b068dcacf9b69
https://github.com/jiasir/playback/blob/58b2a5d669dcfaa8cad50c544a4b068dcacf9b69/playback/glance.py#L74-L82
train
Create the glance database
ethereum/asyncio-cancel-token
cancel_token/token.py
CancelToken.chain
def chain(self, token: 'CancelToken') -> 'CancelToken': """ Return a new CancelToken chaining this and the given token. The new CancelToken's triggered will return True if trigger() has been called on either of the chained tokens, but calling trigger() on the new token has no ef...
python
def chain(self, token: 'CancelToken') -> 'CancelToken': """ Return a new CancelToken chaining this and the given token. The new CancelToken's triggered will return True if trigger() has been called on either of the chained tokens, but calling trigger() on the new token has no ef...
[ "def", "chain", "(", "self", ",", "token", ":", "'CancelToken'", ")", "->", "'CancelToken'", ":", "if", "self", ".", "loop", "!=", "token", ".", "_loop", ":", "raise", "EventLoopMismatch", "(", "\"Chained CancelToken objects must be on the same event loop\"", ")", ...
Return a new CancelToken chaining this and the given token. The new CancelToken's triggered will return True if trigger() has been called on either of the chained tokens, but calling trigger() on the new token has no effect on either of the chained tokens.
[ "Return", "a", "new", "CancelToken", "chaining", "this", "and", "the", "given", "token", "." ]
135395a1a396c50731c03cf570e267c47c612694
https://github.com/ethereum/asyncio-cancel-token/blob/135395a1a396c50731c03cf570e267c47c612694/cancel_token/token.py#L33-L46
train
Returns a new CancelToken that is the same as this one and the given token.
ethereum/asyncio-cancel-token
cancel_token/token.py
CancelToken.triggered_token
def triggered_token(self) -> 'CancelToken': """ Return the token which was triggered. The returned token may be this token or one that it was chained with. """ if self._triggered.is_set(): return self for token in self._chain: if token.triggered: ...
python
def triggered_token(self) -> 'CancelToken': """ Return the token which was triggered. The returned token may be this token or one that it was chained with. """ if self._triggered.is_set(): return self for token in self._chain: if token.triggered: ...
[ "def", "triggered_token", "(", "self", ")", "->", "'CancelToken'", ":", "if", "self", ".", "_triggered", ".", "is_set", "(", ")", ":", "return", "self", "for", "token", "in", "self", ".", "_chain", ":", "if", "token", ".", "triggered", ":", "# Use token....
Return the token which was triggered. The returned token may be this token or one that it was chained with.
[ "Return", "the", "token", "which", "was", "triggered", "." ]
135395a1a396c50731c03cf570e267c47c612694
https://github.com/ethereum/asyncio-cancel-token/blob/135395a1a396c50731c03cf570e267c47c612694/cancel_token/token.py#L55-L68
train
Return the token which was triggered.
ethereum/asyncio-cancel-token
cancel_token/token.py
CancelToken.triggered
def triggered(self) -> bool: """ Return `True` or `False` whether this token has been triggered. """ if self._triggered.is_set(): return True return any(token.triggered for token in self._chain)
python
def triggered(self) -> bool: """ Return `True` or `False` whether this token has been triggered. """ if self._triggered.is_set(): return True return any(token.triggered for token in self._chain)
[ "def", "triggered", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "_triggered", ".", "is_set", "(", ")", ":", "return", "True", "return", "any", "(", "token", ".", "triggered", "for", "token", "in", "self", ".", "_chain", ")" ]
Return `True` or `False` whether this token has been triggered.
[ "Return", "True", "or", "False", "whether", "this", "token", "has", "been", "triggered", "." ]
135395a1a396c50731c03cf570e267c47c612694
https://github.com/ethereum/asyncio-cancel-token/blob/135395a1a396c50731c03cf570e267c47c612694/cancel_token/token.py#L71-L77
train
Return True if this token has been triggered.
ethereum/asyncio-cancel-token
cancel_token/token.py
CancelToken.wait
async def wait(self) -> None: """ Coroutine which returns when this token has been triggered """ if self.triggered_token is not None: return futures = [asyncio.ensure_future(self._triggered.wait(), loop=self.loop)] for token in self._chain: future...
python
async def wait(self) -> None: """ Coroutine which returns when this token has been triggered """ if self.triggered_token is not None: return futures = [asyncio.ensure_future(self._triggered.wait(), loop=self.loop)] for token in self._chain: future...
[ "async", "def", "wait", "(", "self", ")", "->", "None", ":", "if", "self", ".", "triggered_token", "is", "not", "None", ":", "return", "futures", "=", "[", "asyncio", ".", "ensure_future", "(", "self", ".", "_triggered", ".", "wait", "(", ")", ",", "...
Coroutine which returns when this token has been triggered
[ "Coroutine", "which", "returns", "when", "this", "token", "has", "been", "triggered" ]
135395a1a396c50731c03cf570e267c47c612694
https://github.com/ethereum/asyncio-cancel-token/blob/135395a1a396c50731c03cf570e267c47c612694/cancel_token/token.py#L87-L112
train
Coroutine which returns when this token has been triggered
ethereum/asyncio-cancel-token
cancel_token/token.py
CancelToken.cancellable_wait
async def cancellable_wait(self, *awaitables: Awaitable[_R], timeout: float = None) -> _R: """ Wait for the first awaitable to complete, unless we timeout or the token is triggered. Returns the result of the first awaitable to complete. Raises TimeoutError if we timeout or ...
python
async def cancellable_wait(self, *awaitables: Awaitable[_R], timeout: float = None) -> _R: """ Wait for the first awaitable to complete, unless we timeout or the token is triggered. Returns the result of the first awaitable to complete. Raises TimeoutError if we timeout or ...
[ "async", "def", "cancellable_wait", "(", "self", ",", "*", "awaitables", ":", "Awaitable", "[", "_R", "]", ",", "timeout", ":", "float", "=", "None", ")", "->", "_R", ":", "futures", "=", "[", "asyncio", ".", "ensure_future", "(", "a", ",", "loop", "...
Wait for the first awaitable to complete, unless we timeout or the token is triggered. Returns the result of the first awaitable to complete. Raises TimeoutError if we timeout or `~cancel_token.exceptions.OperationCancelled` if the cancel token is triggered. All pendin...
[ "Wait", "for", "the", "first", "awaitable", "to", "complete", "unless", "we", "timeout", "or", "the", "token", "is", "triggered", "." ]
135395a1a396c50731c03cf570e267c47c612694
https://github.com/ethereum/asyncio-cancel-token/blob/135395a1a396c50731c03cf570e267c47c612694/cancel_token/token.py#L114-L153
train
Wait for the first awaitable to complete.
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
_ref_replacer
def _ref_replacer(match, passage): """ Helper to replace xpath/scope/refsDecl on iteration with passage value :param match: A RegExp match :type match: re.SRE_MATCH :param passage: A list with subreference informations :type passage: iter :rtype: basestring :return: Replaced string """...
python
def _ref_replacer(match, passage): """ Helper to replace xpath/scope/refsDecl on iteration with passage value :param match: A RegExp match :type match: re.SRE_MATCH :param passage: A list with subreference informations :type passage: iter :rtype: basestring :return: Replaced string """...
[ "def", "_ref_replacer", "(", "match", ",", "passage", ")", ":", "groups", "=", "match", ".", "groups", "(", ")", "ref", "=", "next", "(", "passage", ")", "if", "ref", "is", "None", ":", "return", "groups", "[", "0", "]", "else", ":", "return", "\"{...
Helper to replace xpath/scope/refsDecl on iteration with passage value :param match: A RegExp match :type match: re.SRE_MATCH :param passage: A list with subreference informations :type passage: iter :rtype: basestring :return: Replaced string
[ "Helper", "to", "replace", "xpath", "/", "scope", "/", "refsDecl", "on", "iteration", "with", "passage", "value" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L959-L975
train
Helper function to replace xpath / scope / refsDecl on iteration with passage value
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
CtsReference.parent
def parent(self) -> Optional['CtsReference']: """ Parent of the actual URN, for example, 1.1 for 1.1.1 :rtype: CtsReference """ if self.start.depth == 1 and (self.end is None or self.end.depth <= 1): return None else: if self.start.depth > 1 and (self.end...
python
def parent(self) -> Optional['CtsReference']: """ Parent of the actual URN, for example, 1.1 for 1.1.1 :rtype: CtsReference """ if self.start.depth == 1 and (self.end is None or self.end.depth <= 1): return None else: if self.start.depth > 1 and (self.end...
[ "def", "parent", "(", "self", ")", "->", "Optional", "[", "'CtsReference'", "]", ":", "if", "self", ".", "start", ".", "depth", "==", "1", "and", "(", "self", ".", "end", "is", "None", "or", "self", ".", "end", ".", "depth", "<=", "1", ")", ":", ...
Parent of the actual URN, for example, 1.1 for 1.1.1 :rtype: CtsReference
[ "Parent", "of", "the", "actual", "URN", "for", "example", "1", ".", "1", "for", "1", ".", "1", ".", "1" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L175-L203
train
Return the parent of the current entry.
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
CtsReference.highest
def highest(self) -> CtsSinglePassageId: """ Return highest reference level For references such as 1.1-1.2.8, with different level, it can be useful to access to the highest node in the hierarchy. In this case, the highest level would be 1.1. The function would return ["1", "1"] .. not...
python
def highest(self) -> CtsSinglePassageId: """ Return highest reference level For references such as 1.1-1.2.8, with different level, it can be useful to access to the highest node in the hierarchy. In this case, the highest level would be 1.1. The function would return ["1", "1"] .. not...
[ "def", "highest", "(", "self", ")", "->", "CtsSinglePassageId", ":", "if", "not", "self", ".", "end", ":", "return", "self", ".", "start", "elif", "len", "(", "self", ".", "start", ")", "<", "len", "(", "self", ".", "end", ")", "and", "len", "(", ...
Return highest reference level For references such as 1.1-1.2.8, with different level, it can be useful to access to the highest node in the hierarchy. In this case, the highest level would be 1.1. The function would return ["1", "1"] .. note:: By default, this property returns the start level...
[ "Return", "highest", "reference", "level" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L206-L223
train
Return the highest reference level for the current ctsSinglePassageId.
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
URN.upTo
def upTo(self, key): """ Returns the urn up to given level using URN Constants :param key: Identifier of the wished resource using URN constants :type key: int :returns: String representation of the partial URN requested :rtype: str :Example: >>> a = URN(...
python
def upTo(self, key): """ Returns the urn up to given level using URN Constants :param key: Identifier of the wished resource using URN constants :type key: int :returns: String representation of the partial URN requested :rtype: str :Example: >>> a = URN(...
[ "def", "upTo", "(", "self", ",", "key", ")", ":", "middle", "=", "[", "component", "for", "component", "in", "[", "self", ".", "__parsed", "[", "\"textgroup\"", "]", ",", "self", ".", "__parsed", "[", "\"work\"", "]", ",", "self", ".", "__parsed", "[...
Returns the urn up to given level using URN Constants :param key: Identifier of the wished resource using URN constants :type key: int :returns: String representation of the partial URN requested :rtype: str :Example: >>> a = URN(urn="urn:cts:latinLit:phi1294.phi...
[ "Returns", "the", "urn", "up", "to", "given", "level", "using", "URN", "Constants" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L534-L612
train
Returns the urn up to given level using URN constants
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation.attribute
def attribute(self): """ Attribute that serves as a reference getter """ refs = re.findall( "\@([a-zA-Z:]+)=\\\?[\'\"]\$"+str(self.refsDecl.count("$"))+"\\\?[\'\"]", self.refsDecl ) return refs[-1]
python
def attribute(self): """ Attribute that serves as a reference getter """ refs = re.findall( "\@([a-zA-Z:]+)=\\\?[\'\"]\$"+str(self.refsDecl.count("$"))+"\\\?[\'\"]", self.refsDecl ) return refs[-1]
[ "def", "attribute", "(", "self", ")", ":", "refs", "=", "re", ".", "findall", "(", "\"\\@([a-zA-Z:]+)=\\\\\\?[\\'\\\"]\\$\"", "+", "str", "(", "self", ".", "refsDecl", ".", "count", "(", "\"$\"", ")", ")", "+", "\"\\\\\\?[\\'\\\"]\"", ",", "self", ".", "re...
Attribute that serves as a reference getter
[ "Attribute", "that", "serves", "as", "a", "reference", "getter" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L770-L777
train
Attribute that serves as a reference getter
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation._parseXpathScope
def _parseXpathScope(self): """ Update xpath and scope property when refsDecl is updated :returns: Scope, Xpath """ rd = self.refsDecl matches = REFSDECL_SPLITTER.findall(rd) return REFSDECL_REPLACER.sub("?", "".join(matches[0:-1])), REFSDECL_REPLACER.sub("?", matches[-1...
python
def _parseXpathScope(self): """ Update xpath and scope property when refsDecl is updated :returns: Scope, Xpath """ rd = self.refsDecl matches = REFSDECL_SPLITTER.findall(rd) return REFSDECL_REPLACER.sub("?", "".join(matches[0:-1])), REFSDECL_REPLACER.sub("?", matches[-1...
[ "def", "_parseXpathScope", "(", "self", ")", ":", "rd", "=", "self", ".", "refsDecl", "matches", "=", "REFSDECL_SPLITTER", ".", "findall", "(", "rd", ")", "return", "REFSDECL_REPLACER", ".", "sub", "(", "\"?\"", ",", "\"\"", ".", "join", "(", "matches", ...
Update xpath and scope property when refsDecl is updated :returns: Scope, Xpath
[ "Update", "xpath", "and", "scope", "property", "when", "refsDecl", "is", "updated" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L779-L786
train
Update xpath and scope property when refsDecl is updated
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation._fromScopeXpathToRefsDecl
def _fromScopeXpathToRefsDecl(self, scope, xpath): """ Update xpath and scope property when refsDecl is updated """ if scope is not None and xpath is not None: _xpath = scope + xpath i = _xpath.find("?") ii = 1 while i >= 0: _xpath...
python
def _fromScopeXpathToRefsDecl(self, scope, xpath): """ Update xpath and scope property when refsDecl is updated """ if scope is not None and xpath is not None: _xpath = scope + xpath i = _xpath.find("?") ii = 1 while i >= 0: _xpath...
[ "def", "_fromScopeXpathToRefsDecl", "(", "self", ",", "scope", ",", "xpath", ")", ":", "if", "scope", "is", "not", "None", "and", "xpath", "is", "not", "None", ":", "_xpath", "=", "scope", "+", "xpath", "i", "=", "_xpath", ".", "find", "(", "\"?\"", ...
Update xpath and scope property when refsDecl is updated
[ "Update", "xpath", "and", "scope", "property", "when", "refsDecl", "is", "updated" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L788-L800
train
Update xpath and scope property when refsDecl is updated
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation.match
def match(self, passageId): """ Given a passageId matches a citation level :param passageId: A passage to match :return: """ if not isinstance(passageId, CtsReference): passageId = CtsReference(passageId) if self.is_root(): return self[passageId....
python
def match(self, passageId): """ Given a passageId matches a citation level :param passageId: A passage to match :return: """ if not isinstance(passageId, CtsReference): passageId = CtsReference(passageId) if self.is_root(): return self[passageId....
[ "def", "match", "(", "self", ",", "passageId", ")", ":", "if", "not", "isinstance", "(", "passageId", ",", "CtsReference", ")", ":", "passageId", "=", "CtsReference", "(", "passageId", ")", "if", "self", ".", "is_root", "(", ")", ":", "return", "self", ...
Given a passageId matches a citation level :param passageId: A passage to match :return:
[ "Given", "a", "passageId", "matches", "a", "citation", "level" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L815-L826
train
Given a passageId matches a citation level returns True if the citation level matches the citation level otherwise False.
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation.fill
def fill(self, passage=None, xpath=None): """ Fill the xpath with given informations :param passage: CapitainsCtsPassage reference :type passage: CtsReference or list or None. Can be list of None and not None :param xpath: If set to True, will return the replaced self.xpath value and no...
python
def fill(self, passage=None, xpath=None): """ Fill the xpath with given informations :param passage: CapitainsCtsPassage reference :type passage: CtsReference or list or None. Can be list of None and not None :param xpath: If set to True, will return the replaced self.xpath value and no...
[ "def", "fill", "(", "self", ",", "passage", "=", "None", ",", "xpath", "=", "None", ")", ":", "if", "xpath", "is", "True", ":", "# Then passage is a string or None", "xpath", "=", "self", ".", "xpath", "replacement", "=", "r\"\\1\"", "if", "isinstance", "(...
Fill the xpath with given informations :param passage: CapitainsCtsPassage reference :type passage: CtsReference or list or None. Can be list of None and not None :param xpath: If set to True, will return the replaced self.xpath value and not the whole self.refsDecl :type xpath: Boolean...
[ "Fill", "the", "xpath", "with", "given", "informations" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L828-L872
train
Fill the xpath with given informations
Capitains/MyCapytain
MyCapytain/common/reference/_capitains_cts.py
Citation.ingest
def ingest(resource, xpath=".//tei:cRefPattern"): """ Ingest a resource and store data in its instance :param resource: XML node cRefPattern or list of them in ASC hierarchy order (deepest to highest, eg. lines to poem to book) :type resource: [lxml.etree._Element] :param xpath: XPath t...
python
def ingest(resource, xpath=".//tei:cRefPattern"): """ Ingest a resource and store data in its instance :param resource: XML node cRefPattern or list of them in ASC hierarchy order (deepest to highest, eg. lines to poem to book) :type resource: [lxml.etree._Element] :param xpath: XPath t...
[ "def", "ingest", "(", "resource", ",", "xpath", "=", "\".//tei:cRefPattern\"", ")", ":", "if", "len", "(", "resource", ")", "==", "0", "and", "isinstance", "(", "resource", ",", "list", ")", ":", "return", "None", "elif", "isinstance", "(", "resource", "...
Ingest a resource and store data in its instance :param resource: XML node cRefPattern or list of them in ASC hierarchy order (deepest to highest, eg. lines to poem to book) :type resource: [lxml.etree._Element] :param xpath: XPath to use to retrieve citation :type xpath: str :...
[ "Ingest", "a", "resource", "and", "store", "data", "in", "its", "instance" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/reference/_capitains_cts.py#L924-L956
train
Ingest a resource and store data in its instance
totalgood/twip
tweetget/core.py
get_tweets_count_times
def get_tweets_count_times(twitter, count, query=None): r""" hits the twitter api `count` times and grabs tweets for the indicated query""" # get id to start from oldest_id, newest_id = _get_oldest_id(query=query) newest_id = newest_id or oldest_id all_tweets = [] i = 0 while i < count: ...
python
def get_tweets_count_times(twitter, count, query=None): r""" hits the twitter api `count` times and grabs tweets for the indicated query""" # get id to start from oldest_id, newest_id = _get_oldest_id(query=query) newest_id = newest_id or oldest_id all_tweets = [] i = 0 while i < count: ...
[ "def", "get_tweets_count_times", "(", "twitter", ",", "count", ",", "query", "=", "None", ")", ":", "# get id to start from", "oldest_id", ",", "newest_id", "=", "_get_oldest_id", "(", "query", "=", "query", ")", "newest_id", "=", "newest_id", "or", "oldest_id",...
r""" hits the twitter api `count` times and grabs tweets for the indicated query
[ "r", "hits", "the", "twitter", "api", "count", "times", "and", "grabs", "tweets", "for", "the", "indicated", "query" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/tweetget/core.py#L41-L86
train
r Gets the tweets for the given query and returns the specified count times.
aiidateam/aiida-codtools
aiida_codtools/parsers/cif_base.py
CifBaseParser.parse
def parse(self, **kwargs): """Parse the contents of the output files retrieved in the `FolderData`.""" try: output_folder = self.retrieved except exceptions.NotExistent: return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER filename_stdout = self.node.get_attribute('o...
python
def parse(self, **kwargs): """Parse the contents of the output files retrieved in the `FolderData`.""" try: output_folder = self.retrieved except exceptions.NotExistent: return self.exit_codes.ERROR_NO_RETRIEVED_FOLDER filename_stdout = self.node.get_attribute('o...
[ "def", "parse", "(", "self", ",", "*", "*", "kwargs", ")", ":", "try", ":", "output_folder", "=", "self", ".", "retrieved", "except", "exceptions", ".", "NotExistent", ":", "return", "self", ".", "exit_codes", ".", "ERROR_NO_RETRIEVED_FOLDER", "filename_stdout...
Parse the contents of the output files retrieved in the `FolderData`.
[ "Parse", "the", "contents", "of", "the", "output", "files", "retrieved", "in", "the", "FolderData", "." ]
da5e4259b7a2e86cf0cc3f997e11dd36d445fa94
https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/parsers/cif_base.py#L28-L57
train
Parse the contents of the output files retrieved in the FolderData.
aiidateam/aiida-codtools
aiida_codtools/parsers/cif_base.py
CifBaseParser.parse_stdout
def parse_stdout(self, filelike): """Parse the content written by the script to standard out into a `CifData` object. :param filelike: filelike object of stdout :returns: an exit code in case of an error, None otherwise """ from CifFile import StarError if not filelike....
python
def parse_stdout(self, filelike): """Parse the content written by the script to standard out into a `CifData` object. :param filelike: filelike object of stdout :returns: an exit code in case of an error, None otherwise """ from CifFile import StarError if not filelike....
[ "def", "parse_stdout", "(", "self", ",", "filelike", ")", ":", "from", "CifFile", "import", "StarError", "if", "not", "filelike", ".", "read", "(", ")", ".", "strip", "(", ")", ":", "return", "self", ".", "exit_codes", ".", "ERROR_EMPTY_OUTPUT_FILE", "try"...
Parse the content written by the script to standard out into a `CifData` object. :param filelike: filelike object of stdout :returns: an exit code in case of an error, None otherwise
[ "Parse", "the", "content", "written", "by", "the", "script", "to", "standard", "out", "into", "a", "CifData", "object", "." ]
da5e4259b7a2e86cf0cc3f997e11dd36d445fa94
https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/parsers/cif_base.py#L59-L79
train
Parse the content written by the script to standard out into a CifData object.
aiidateam/aiida-codtools
aiida_codtools/parsers/cif_base.py
CifBaseParser.parse_stderr
def parse_stderr(self, filelike): """Parse the content written by the script to standard err. :param filelike: filelike object of stderr :returns: an exit code in case of an error, None otherwise """ marker_error = 'ERROR,' marker_warning = 'WARNING,' messages =...
python
def parse_stderr(self, filelike): """Parse the content written by the script to standard err. :param filelike: filelike object of stderr :returns: an exit code in case of an error, None otherwise """ marker_error = 'ERROR,' marker_warning = 'WARNING,' messages =...
[ "def", "parse_stderr", "(", "self", ",", "filelike", ")", ":", "marker_error", "=", "'ERROR,'", "marker_warning", "=", "'WARNING,'", "messages", "=", "{", "'errors'", ":", "[", "]", ",", "'warnings'", ":", "[", "]", "}", "for", "line", "in", "filelike", ...
Parse the content written by the script to standard err. :param filelike: filelike object of stderr :returns: an exit code in case of an error, None otherwise
[ "Parse", "the", "content", "written", "by", "the", "script", "to", "standard", "err", "." ]
da5e4259b7a2e86cf0cc3f997e11dd36d445fa94
https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/parsers/cif_base.py#L81-L105
train
Parse the content written by the script to standard err.
ivilata/pymultihash
multihash/funcs.py
FuncReg.reset
def reset(cls): """Reset the registry to the standard multihash functions.""" # Maps function names (hyphens or underscores) to registered functions. cls._func_from_name = {} # Maps hashlib names to registered functions. cls._func_from_hash = {} # Hashlib compatibility ...
python
def reset(cls): """Reset the registry to the standard multihash functions.""" # Maps function names (hyphens or underscores) to registered functions. cls._func_from_name = {} # Maps hashlib names to registered functions. cls._func_from_hash = {} # Hashlib compatibility ...
[ "def", "reset", "(", "cls", ")", ":", "# Maps function names (hyphens or underscores) to registered functions.", "cls", ".", "_func_from_name", "=", "{", "}", "# Maps hashlib names to registered functions.", "cls", ".", "_func_from_hash", "=", "{", "}", "# Hashlib compatibili...
Reset the registry to the standard multihash functions.
[ "Reset", "the", "registry", "to", "the", "standard", "multihash", "functions", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L104-L118
train
Reset the registry to the standard multihash functions.
ivilata/pymultihash
multihash/funcs.py
FuncReg.get
def get(cls, func_hint): """Return a registered hash function matching the given hint. The hint may be a `Func` member, a function name (with hyphens or underscores), or its code. A `Func` member is returned for standard multihash functions and an integer code for application-specific ...
python
def get(cls, func_hint): """Return a registered hash function matching the given hint. The hint may be a `Func` member, a function name (with hyphens or underscores), or its code. A `Func` member is returned for standard multihash functions and an integer code for application-specific ...
[ "def", "get", "(", "cls", ",", "func_hint", ")", ":", "# Different possibilities of `func_hint`, most to least probable.", "try", ":", "# `Func` member (or its value)", "return", "Func", "(", "func_hint", ")", "except", "ValueError", ":", "pass", "if", "func_hint", "in"...
Return a registered hash function matching the given hint. The hint may be a `Func` member, a function name (with hyphens or underscores), or its code. A `Func` member is returned for standard multihash functions and an integer code for application-specific ones. If no matching functio...
[ "Return", "a", "registered", "hash", "function", "matching", "the", "given", "hint", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L121-L145
train
Return a registered hash function matching the given hint.
ivilata/pymultihash
multihash/funcs.py
FuncReg._do_register
def _do_register(cls, code, name, hash_name=None, hash_new=None): """Add hash function data to the registry without checks.""" cls._func_from_name[name.replace('-', '_')] = code cls._func_from_name[name.replace('_', '-')] = code if hash_name: cls._func_from_hash[hash_name] = ...
python
def _do_register(cls, code, name, hash_name=None, hash_new=None): """Add hash function data to the registry without checks.""" cls._func_from_name[name.replace('-', '_')] = code cls._func_from_name[name.replace('_', '-')] = code if hash_name: cls._func_from_hash[hash_name] = ...
[ "def", "_do_register", "(", "cls", ",", "code", ",", "name", ",", "hash_name", "=", "None", ",", "hash_new", "=", "None", ")", ":", "cls", ".", "_func_from_name", "[", "name", ".", "replace", "(", "'-'", ",", "'_'", ")", "]", "=", "code", "cls", "....
Add hash function data to the registry without checks.
[ "Add", "hash", "function", "data", "to", "the", "registry", "without", "checks", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L148-L154
train
Add hash function data to the registry without checks.
ivilata/pymultihash
multihash/funcs.py
FuncReg.register
def register(cls, code, name, hash_name=None, hash_new=None): """Add an application-specific function to the registry. Registers a function with the given `code` (an integer) and `name` (a string, which is added both with only hyphens and only underscores), as well as an optional `hash_...
python
def register(cls, code, name, hash_name=None, hash_new=None): """Add an application-specific function to the registry. Registers a function with the given `code` (an integer) and `name` (a string, which is added both with only hyphens and only underscores), as well as an optional `hash_...
[ "def", "register", "(", "cls", ",", "code", ",", "name", ",", "hash_name", "=", "None", ",", "hash_new", "=", "None", ")", ":", "if", "not", "_is_app_specific_func", "(", "code", ")", ":", "raise", "ValueError", "(", "\"only application-specific functions can ...
Add an application-specific function to the registry. Registers a function with the given `code` (an integer) and `name` (a string, which is added both with only hyphens and only underscores), as well as an optional `hash_name` and `hash_new` constructor for hashlib compatibility. If t...
[ "Add", "an", "application", "-", "specific", "function", "to", "the", "registry", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L157-L199
train
Add an application - specific function to the registry.
ivilata/pymultihash
multihash/funcs.py
FuncReg.unregister
def unregister(cls, code): """Remove an application-specific function from the registry. Unregisters the function with the given `code` (an integer). If the function is not registered, a `KeyError` is raised. Unregistering a function with a `code` not in the application-specific range...
python
def unregister(cls, code): """Remove an application-specific function from the registry. Unregisters the function with the given `code` (an integer). If the function is not registered, a `KeyError` is raised. Unregistering a function with a `code` not in the application-specific range...
[ "def", "unregister", "(", "cls", ",", "code", ")", ":", "if", "code", "in", "Func", ":", "raise", "ValueError", "(", "\"only application-specific functions can be unregistered\"", ")", "# Remove mapping to function by name.", "func_names", "=", "{", "n", "for", "(", ...
Remove an application-specific function from the registry. Unregisters the function with the given `code` (an integer). If the function is not registered, a `KeyError` is raised. Unregistering a function with a `code` not in the application-specific range (0x00-0xff) raises a `ValueEr...
[ "Remove", "an", "application", "-", "specific", "function", "from", "the", "registry", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L202-L230
train
Remove an application - specific function from the registry.
ivilata/pymultihash
multihash/funcs.py
FuncReg.hash_from_func
def hash_from_func(cls, func): """Return a hashlib-compatible object for the multihash `func`. If the `func` is registered but no hashlib-compatible constructor is available for it, `None` is returned. If the `func` is not registered, a `KeyError` is raised. >>> h = FuncReg.ha...
python
def hash_from_func(cls, func): """Return a hashlib-compatible object for the multihash `func`. If the `func` is registered but no hashlib-compatible constructor is available for it, `None` is returned. If the `func` is not registered, a `KeyError` is raised. >>> h = FuncReg.ha...
[ "def", "hash_from_func", "(", "cls", ",", "func", ")", ":", "new", "=", "cls", ".", "_func_hash", "[", "func", "]", ".", "new", "return", "new", "(", ")", "if", "new", "else", "None" ]
Return a hashlib-compatible object for the multihash `func`. If the `func` is registered but no hashlib-compatible constructor is available for it, `None` is returned. If the `func` is not registered, a `KeyError` is raised. >>> h = FuncReg.hash_from_func(Func.sha2_256) >>> h....
[ "Return", "a", "hashlib", "-", "compatible", "object", "for", "the", "multihash", "func", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/funcs.py#L247-L259
train
Return a hashlib - compatible object for the multihash func.
SHDShim/pytheos
pytheos/plot/thermal_fit.py
thermal_data
def thermal_data(data, figsize=(12, 4), ms_data=50, v_label='Unit-cell volume $(\mathrm{\AA}^3)$', pdf_filen=None, title='P-V-T data'): """ plot P-V-T data before fitting :param data: {'p': unumpy array, 'v': unumpy array, 'temp': unumpy array} :param eoscurves: {'v': ...
python
def thermal_data(data, figsize=(12, 4), ms_data=50, v_label='Unit-cell volume $(\mathrm{\AA}^3)$', pdf_filen=None, title='P-V-T data'): """ plot P-V-T data before fitting :param data: {'p': unumpy array, 'v': unumpy array, 'temp': unumpy array} :param eoscurves: {'v': ...
[ "def", "thermal_data", "(", "data", ",", "figsize", "=", "(", "12", ",", "4", ")", ",", "ms_data", "=", "50", ",", "v_label", "=", "'Unit-cell volume $(\\mathrm{\\AA}^3)$'", ",", "pdf_filen", "=", "None", ",", "title", "=", "'P-V-T data'", ")", ":", "# bas...
plot P-V-T data before fitting :param data: {'p': unumpy array, 'v': unumpy array, 'temp': unumpy array} :param eoscurves: {'v': unumpy array, '300': unumpy array at the temperature ....} :param v_label: label for volume axis :param figsize: figure size :param ms_data: marker size for d...
[ "plot", "P", "-", "V", "-", "T", "data", "before", "fitting" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/plot/thermal_fit.py#L15-L68
train
plot P - V - T data for the current thermal process
SHDShim/pytheos
pytheos/plot/thermal_fit.py
thermal_fit_result
def thermal_fit_result(fit_result, v_residual=None, v_label='Unit-cell volume $(\mathrm{\AA}^3)$', temp_fitline=np.asarray( [300., 1000., 1500., 2000., 2500., 3000.]), figsize=(5, 5), height_ratios=(3, 1), ms_data=50, ...
python
def thermal_fit_result(fit_result, v_residual=None, v_label='Unit-cell volume $(\mathrm{\AA}^3)$', temp_fitline=np.asarray( [300., 1000., 1500., 2000., 2500., 3000.]), figsize=(5, 5), height_ratios=(3, 1), ms_data=50, ...
[ "def", "thermal_fit_result", "(", "fit_result", ",", "v_residual", "=", "None", ",", "v_label", "=", "'Unit-cell volume $(\\mathrm{\\AA}^3)$'", ",", "temp_fitline", "=", "np", ".", "asarray", "(", "[", "300.", ",", "1000.", ",", "1500.", ",", "2000.", ",", "25...
plot P-V-T EOS curve fitting result :param fit_result: lmfit result object, see example jnb file for detail :param v_label: label for volume axis :param temp_fitline: temperatures to calculate isothermal compression curves, default = [300., 1000., 1500., 2000., 2500., 3000.] :param figsize: fig...
[ "plot", "P", "-", "V", "-", "T", "EOS", "curve", "fitting", "result" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/plot/thermal_fit.py#L74-L151
train
plot P - V - T EOS curve fitting result
ivilata/pymultihash
multihash/multihash.py
_do_digest
def _do_digest(data, func): """Return the binary digest of `data` with the given `func`.""" func = FuncReg.get(func) hash = FuncReg.hash_from_func(func) if not hash: raise ValueError("no available hash function for hash", func) hash.update(data) return bytes(hash.digest())
python
def _do_digest(data, func): """Return the binary digest of `data` with the given `func`.""" func = FuncReg.get(func) hash = FuncReg.hash_from_func(func) if not hash: raise ValueError("no available hash function for hash", func) hash.update(data) return bytes(hash.digest())
[ "def", "_do_digest", "(", "data", ",", "func", ")", ":", "func", "=", "FuncReg", ".", "get", "(", "func", ")", "hash", "=", "FuncReg", ".", "hash_from_func", "(", "func", ")", "if", "not", "hash", ":", "raise", "ValueError", "(", "\"no available hash fun...
Return the binary digest of `data` with the given `func`.
[ "Return", "the", "binary", "digest", "of", "data", "with", "the", "given", "func", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L16-L23
train
Return the binary digest of data with the given func.
ivilata/pymultihash
multihash/multihash.py
digest
def digest(data, func): """Hash the given `data` into a new `Multihash`. The given hash function `func` is used to perform the hashing. It must be a registered hash function (see `FuncReg`). >>> data = b'foo' >>> mh = digest(data, Func.sha1) >>> mh.encode('base64') b'ERQL7se16j8P28ldDdR/P...
python
def digest(data, func): """Hash the given `data` into a new `Multihash`. The given hash function `func` is used to perform the hashing. It must be a registered hash function (see `FuncReg`). >>> data = b'foo' >>> mh = digest(data, Func.sha1) >>> mh.encode('base64') b'ERQL7se16j8P28ldDdR/P...
[ "def", "digest", "(", "data", ",", "func", ")", ":", "digest", "=", "_do_digest", "(", "data", ",", "func", ")", "return", "Multihash", "(", "func", ",", "digest", ")" ]
Hash the given `data` into a new `Multihash`. The given hash function `func` is used to perform the hashing. It must be a registered hash function (see `FuncReg`). >>> data = b'foo' >>> mh = digest(data, Func.sha1) >>> mh.encode('base64') b'ERQL7se16j8P28ldDdR/PFvCddqKMw=='
[ "Hash", "the", "given", "data", "into", "a", "new", "Multihash", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L186-L198
train
Hash the given data into a new Multihash.
ivilata/pymultihash
multihash/multihash.py
decode
def decode(mhash, encoding=None): r"""Decode a multihash-encoded digest into a `Multihash`. If `encoding` is `None`, a binary digest is assumed. >>> mhash = b'\x11\x0a\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]' >>> mh = decode(mhash) >>> mh == (Func.sha1, mhash[2:]) True If the name of an `encodi...
python
def decode(mhash, encoding=None): r"""Decode a multihash-encoded digest into a `Multihash`. If `encoding` is `None`, a binary digest is assumed. >>> mhash = b'\x11\x0a\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]' >>> mh = decode(mhash) >>> mh == (Func.sha1, mhash[2:]) True If the name of an `encodi...
[ "def", "decode", "(", "mhash", ",", "encoding", "=", "None", ")", ":", "mhash", "=", "bytes", "(", "mhash", ")", "if", "encoding", ":", "mhash", "=", "CodecReg", ".", "get_decoder", "(", "encoding", ")", "(", "mhash", ")", "try", ":", "func", "=", ...
r"""Decode a multihash-encoded digest into a `Multihash`. If `encoding` is `None`, a binary digest is assumed. >>> mhash = b'\x11\x0a\x0b\xee\xc7\xb5\xea?\x0f\xdb\xc9]' >>> mh = decode(mhash) >>> mh == (Func.sha1, mhash[2:]) True If the name of an `encoding` is specified, it is used to decode...
[ "r", "Decode", "a", "multihash", "-", "encoded", "digest", "into", "a", "Multihash", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L201-L235
train
r Decode a multihash - encoded digest into a Multihash object.
ivilata/pymultihash
multihash/multihash.py
Multihash.from_hash
def from_hash(self, hash): """Create a `Multihash` from a hashlib-compatible `hash` object. >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> digest = hash.digest() >>> mh = Multihash.from_hash(hash) >>> mh == (Func.sha1, digest) True...
python
def from_hash(self, hash): """Create a `Multihash` from a hashlib-compatible `hash` object. >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> digest = hash.digest() >>> mh = Multihash.from_hash(hash) >>> mh == (Func.sha1, digest) True...
[ "def", "from_hash", "(", "self", ",", "hash", ")", ":", "try", ":", "func", "=", "FuncReg", ".", "func_from_hash", "(", "hash", ")", "except", "KeyError", "as", "ke", ":", "raise", "ValueError", "(", "\"no matching multihash function\"", ",", "hash", ".", ...
Create a `Multihash` from a hashlib-compatible `hash` object. >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> digest = hash.digest() >>> mh = Multihash.from_hash(hash) >>> mh == (Func.sha1, digest) True Application-specific hash fu...
[ "Create", "a", "Multihash", "from", "a", "hashlib", "-", "compatible", "hash", "object", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L74-L97
train
Create a Multihash object from a hashlib - compatible hash object.
ivilata/pymultihash
multihash/multihash.py
Multihash.encode
def encode(self, encoding=None): r"""Encode into a multihash-encoded digest. If `encoding` is `None`, a binary digest is produced: >>> mh = Multihash(0x01, b'TEST') >>> mh.encode() b'\x01\x04TEST' If the name of an `encoding` is specified, it is used to encode the ...
python
def encode(self, encoding=None): r"""Encode into a multihash-encoded digest. If `encoding` is `None`, a binary digest is produced: >>> mh = Multihash(0x01, b'TEST') >>> mh.encode() b'\x01\x04TEST' If the name of an `encoding` is specified, it is used to encode the ...
[ "def", "encode", "(", "self", ",", "encoding", "=", "None", ")", ":", "try", ":", "fc", "=", "self", ".", "func", ".", "value", "except", "AttributeError", ":", "# application-specific function code", "fc", "=", "self", ".", "func", "mhash", "=", "bytes", ...
r"""Encode into a multihash-encoded digest. If `encoding` is `None`, a binary digest is produced: >>> mh = Multihash(0x01, b'TEST') >>> mh.encode() b'\x01\x04TEST' If the name of an `encoding` is specified, it is used to encode the binary digest before returning it (se...
[ "r", "Encode", "into", "a", "multihash", "-", "encoded", "digest", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L120-L145
train
r Encode into a multihash - encoded digest.
ivilata/pymultihash
multihash/multihash.py
Multihash.verify
def verify(self, data): r"""Does the given `data` hash to the digest in this `Multihash`? >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> mh = Multihash.from_hash(hash) >>> mh.verify(data) True >>> mh.verify(b'foobar') False...
python
def verify(self, data): r"""Does the given `data` hash to the digest in this `Multihash`? >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> mh = Multihash.from_hash(hash) >>> mh.verify(data) True >>> mh.verify(b'foobar') False...
[ "def", "verify", "(", "self", ",", "data", ")", ":", "digest", "=", "_do_digest", "(", "data", ",", "self", ".", "func", ")", "return", "digest", "[", ":", "len", "(", "self", ".", "digest", ")", "]", "==", "self", ".", "digest" ]
r"""Does the given `data` hash to the digest in this `Multihash`? >>> import hashlib >>> data = b'foo' >>> hash = hashlib.sha1(data) >>> mh = Multihash.from_hash(hash) >>> mh.verify(data) True >>> mh.verify(b'foobar') False Application-specific h...
[ "r", "Does", "the", "given", "data", "hash", "to", "the", "digest", "in", "this", "Multihash", "?" ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L147-L163
train
r Does the given data hash to the digest in this Multihash?
ivilata/pymultihash
multihash/multihash.py
Multihash.truncate
def truncate(self, length): """Return a new `Multihash` with a shorter digest `length`. If the given `length` is greater than the original, a `ValueError` is raised. >>> mh1 = Multihash(0x01, b'FOOBAR') >>> mh2 = mh1.truncate(3) >>> mh2 == (0x01, b'FOO') True ...
python
def truncate(self, length): """Return a new `Multihash` with a shorter digest `length`. If the given `length` is greater than the original, a `ValueError` is raised. >>> mh1 = Multihash(0x01, b'FOOBAR') >>> mh2 = mh1.truncate(3) >>> mh2 == (0x01, b'FOO') True ...
[ "def", "truncate", "(", "self", ",", "length", ")", ":", "if", "length", ">", "len", "(", "self", ".", "digest", ")", ":", "raise", "ValueError", "(", "\"cannot enlarge the original digest by %d bytes\"", "%", "(", "length", "-", "len", "(", "self", ".", "...
Return a new `Multihash` with a shorter digest `length`. If the given `length` is greater than the original, a `ValueError` is raised. >>> mh1 = Multihash(0x01, b'FOOBAR') >>> mh2 = mh1.truncate(3) >>> mh2 == (0x01, b'FOO') True >>> mh3 = mh1.truncate(10) ...
[ "Return", "a", "new", "Multihash", "with", "a", "shorter", "digest", "length", "." ]
093365f20f6d8627c1fae13e0f4e0b35e9b39ad2
https://github.com/ivilata/pymultihash/blob/093365f20f6d8627c1fae13e0f4e0b35e9b39ad2/multihash/multihash.py#L165-L183
train
Return a new Multihash with a shorter digest length.
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.set
def set(self, key: URIRef, value: Union[Literal, BNode, URIRef, str, int], lang: Optional[str]=None): """ Set the VALUE for KEY predicate in the Metadata Graph :param key: Predicate to be set (eg. DCT.creator) :param value: Value to be stored (eg. "Cicero") :param lang: [Optional] Langu...
python
def set(self, key: URIRef, value: Union[Literal, BNode, URIRef, str, int], lang: Optional[str]=None): """ Set the VALUE for KEY predicate in the Metadata Graph :param key: Predicate to be set (eg. DCT.creator) :param value: Value to be stored (eg. "Cicero") :param lang: [Optional] Langu...
[ "def", "set", "(", "self", ",", "key", ":", "URIRef", ",", "value", ":", "Union", "[", "Literal", ",", "BNode", ",", "URIRef", ",", "str", ",", "int", "]", ",", "lang", ":", "Optional", "[", "str", "]", "=", "None", ")", ":", "if", "not", "isin...
Set the VALUE for KEY predicate in the Metadata Graph :param key: Predicate to be set (eg. DCT.creator) :param value: Value to be stored (eg. "Cicero") :param lang: [Optional] Language of the value (eg. "la")
[ "Set", "the", "VALUE", "for", "KEY", "predicate", "in", "the", "Metadata", "Graph" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L55-L70
train
Set the VALUE for KEY predicate in the Metadata Graph
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.add
def add(self, key, value, lang=None): """ Add a triple to the graph related to this node :param key: Predicate of the triple :param value: Object of the triple :param lang: Language of the triple if applicable """ if not isinstance(value, Literal) and lang is not None: ...
python
def add(self, key, value, lang=None): """ Add a triple to the graph related to this node :param key: Predicate of the triple :param value: Object of the triple :param lang: Language of the triple if applicable """ if not isinstance(value, Literal) and lang is not None: ...
[ "def", "add", "(", "self", ",", "key", ",", "value", ",", "lang", "=", "None", ")", ":", "if", "not", "isinstance", "(", "value", ",", "Literal", ")", "and", "lang", "is", "not", "None", ":", "value", "=", "Literal", "(", "value", ",", "lang", "=...
Add a triple to the graph related to this node :param key: Predicate of the triple :param value: Object of the triple :param lang: Language of the triple if applicable
[ "Add", "a", "triple", "to", "the", "graph", "related", "to", "this", "node" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L72-L87
train
Adds a triple to the graph related to this node.
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.get
def get(self, key, lang=None): """ Returns triple related to this node. Can filter on lang :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef """ if lang is not None: for o in self.graph.ob...
python
def get(self, key, lang=None): """ Returns triple related to this node. Can filter on lang :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef """ if lang is not None: for o in self.graph.ob...
[ "def", "get", "(", "self", ",", "key", ",", "lang", "=", "None", ")", ":", "if", "lang", "is", "not", "None", ":", "for", "o", "in", "self", ".", "graph", ".", "objects", "(", "self", ".", "asNode", "(", ")", ",", "key", ")", ":", "if", "o", ...
Returns triple related to this node. Can filter on lang :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef
[ "Returns", "triple", "related", "to", "this", "node", ".", "Can", "filter", "on", "lang" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L89-L102
train
Returns a list of triple related to this node. Can filter on lang
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.get_single
def get_single(self, key, lang=None): """ Returns a single triple related to this node. :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef """ if not isinstance(key, URIRef): key = URIRef(k...
python
def get_single(self, key, lang=None): """ Returns a single triple related to this node. :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef """ if not isinstance(key, URIRef): key = URIRef(k...
[ "def", "get_single", "(", "self", ",", "key", ",", "lang", "=", "None", ")", ":", "if", "not", "isinstance", "(", "key", ",", "URIRef", ")", ":", "key", "=", "URIRef", "(", "key", ")", "if", "lang", "is", "not", "None", ":", "default", "=", "None...
Returns a single triple related to this node. :param key: Predicate of the triple :param lang: Language of the triple if applicable :rtype: Literal or BNode or URIRef
[ "Returns", "a", "single", "triple", "related", "to", "this", "node", "." ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L104-L123
train
Returns a single triple related to this node.
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.remove
def remove(self, predicate=None, obj=None): """ Remove triple matching the predicate or the object :param predicate: Predicate to match, None to match all :param obj: Object to match, None to match all """ self.graph.remove((self.asNode(), predicate, obj))
python
def remove(self, predicate=None, obj=None): """ Remove triple matching the predicate or the object :param predicate: Predicate to match, None to match all :param obj: Object to match, None to match all """ self.graph.remove((self.asNode(), predicate, obj))
[ "def", "remove", "(", "self", ",", "predicate", "=", "None", ",", "obj", "=", "None", ")", ":", "self", ".", "graph", ".", "remove", "(", "(", "self", ".", "asNode", "(", ")", ",", "predicate", ",", "obj", ")", ")" ]
Remove triple matching the predicate or the object :param predicate: Predicate to match, None to match all :param obj: Object to match, None to match all
[ "Remove", "triple", "matching", "the", "predicate", "or", "the", "object" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L139-L145
train
Remove triple matching the predicate or the object
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.unlink
def unlink(self, subj=None, predicate=None): """ Remove triple where Metadata is the object :param subj: Subject to match, None to match all :param predicate: Predicate to match, None to match all """ self.graph.remove((subj, predicate, self.asNode()))
python
def unlink(self, subj=None, predicate=None): """ Remove triple where Metadata is the object :param subj: Subject to match, None to match all :param predicate: Predicate to match, None to match all """ self.graph.remove((subj, predicate, self.asNode()))
[ "def", "unlink", "(", "self", ",", "subj", "=", "None", ",", "predicate", "=", "None", ")", ":", "self", ".", "graph", ".", "remove", "(", "(", "subj", ",", "predicate", ",", "self", ".", "asNode", "(", ")", ")", ")" ]
Remove triple where Metadata is the object :param subj: Subject to match, None to match all :param predicate: Predicate to match, None to match all
[ "Remove", "triple", "where", "Metadata", "is", "the", "object" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L147-L153
train
Remove triple where Metadata is the object
Capitains/MyCapytain
MyCapytain/common/metadata.py
Metadata.getOr
def getOr(subject, predicate, *args, **kwargs): """ Retrieve a metadata node or generate a new one :param subject: Subject to which the metadata node should be connected :param predicate: Predicate by which the metadata node should be connected :return: Metadata for given node :...
python
def getOr(subject, predicate, *args, **kwargs): """ Retrieve a metadata node or generate a new one :param subject: Subject to which the metadata node should be connected :param predicate: Predicate by which the metadata node should be connected :return: Metadata for given node :...
[ "def", "getOr", "(", "subject", ",", "predicate", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "(", "subject", ",", "predicate", ",", "None", ")", "in", "get_graph", "(", ")", ":", "return", "Metadata", "(", "node", "=", "get_graph", ...
Retrieve a metadata node or generate a new one :param subject: Subject to which the metadata node should be connected :param predicate: Predicate by which the metadata node should be connected :return: Metadata for given node :rtype: Metadata
[ "Retrieve", "a", "metadata", "node", "or", "generate", "a", "new", "one" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/metadata.py#L235-L246
train
Retrieve a metadata node or generate a new one if it does not exist
aiidateam/aiida-codtools
aiida_codtools/cli/misc/cif_import.py
launch_cif_import
def launch_cif_import(group, database, max_entries, number_species, skip_partial_occupancies, importer_server, importer_db_host, importer_db_name, importer_db_password, importer_api_url, importer_api_key, count_entries, batch_count, dry_run, verbose): """Import cif files from various structural databases, s...
python
def launch_cif_import(group, database, max_entries, number_species, skip_partial_occupancies, importer_server, importer_db_host, importer_db_name, importer_db_password, importer_api_url, importer_api_key, count_entries, batch_count, dry_run, verbose): """Import cif files from various structural databases, s...
[ "def", "launch_cif_import", "(", "group", ",", "database", ",", "max_entries", ",", "number_species", ",", "skip_partial_occupancies", ",", "importer_server", ",", "importer_db_host", ",", "importer_db_name", ",", "importer_db_password", ",", "importer_api_url", ",", "i...
Import cif files from various structural databases, store them as CifData nodes and add them to a Group. Note that to determine which cif files are already contained within the Group in order to avoid duplication, the attribute 'source.id' of the CifData is compared to the source id of the imported cif entry. ...
[ "Import", "cif", "files", "from", "various", "structural", "databases", "store", "them", "as", "CifData", "nodes", "and", "add", "them", "to", "a", "Group", "." ]
da5e4259b7a2e86cf0cc3f997e11dd36d445fa94
https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/cli/misc/cif_import.py#L55-L215
train
Launches a CifData import on the CifData database.
jedie/PyHardLinkBackup
PyHardLinkBackup/phlb/add.py
add_dir_entry
def add_dir_entry(backup_run, dir_entry_path, process_bar, result): """ :param backup_run: :param dir_entry_path: filesystem_walk.DirEntryPath() instance :param process_bar: """ # print(dir_entry_path.pformat()) # print(dir_entry_path.stat.st_nlink) backup_entry = Path2(dir_entry_path.p...
python
def add_dir_entry(backup_run, dir_entry_path, process_bar, result): """ :param backup_run: :param dir_entry_path: filesystem_walk.DirEntryPath() instance :param process_bar: """ # print(dir_entry_path.pformat()) # print(dir_entry_path.stat.st_nlink) backup_entry = Path2(dir_entry_path.p...
[ "def", "add_dir_entry", "(", "backup_run", ",", "dir_entry_path", ",", "process_bar", ",", "result", ")", ":", "# print(dir_entry_path.pformat())", "# print(dir_entry_path.stat.st_nlink)", "backup_entry", "=", "Path2", "(", "dir_entry_path", ".", "path", ")", "filesize", ...
:param backup_run: :param dir_entry_path: filesystem_walk.DirEntryPath() instance :param process_bar:
[ ":", "param", "backup_run", ":", ":", "param", "dir_entry_path", ":", "filesystem_walk", ".", "DirEntryPath", "()", "instance", ":", "param", "process_bar", ":" ]
be28666834d2d9e3d8aac1b661cb2d5bd4056c29
https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/add.py#L86-L120
train
Add a directory entry to the backup_run.
jedie/PyHardLinkBackup
PyHardLinkBackup/backup_app/migrations/0004_BackupRun_ini_file_20160203_1415.py
forwards_func
def forwards_func(apps, schema_editor): """ manage migrate backup_app 0004_BackupRun_ini_file_20160203_1415 """ print("\n") create_count = 0 BackupRun = apps.get_model("backup_app", "BackupRun") # historical version of BackupRun backup_runs = BackupRun.objects.all() for backup_run in ba...
python
def forwards_func(apps, schema_editor): """ manage migrate backup_app 0004_BackupRun_ini_file_20160203_1415 """ print("\n") create_count = 0 BackupRun = apps.get_model("backup_app", "BackupRun") # historical version of BackupRun backup_runs = BackupRun.objects.all() for backup_run in ba...
[ "def", "forwards_func", "(", "apps", ",", "schema_editor", ")", ":", "print", "(", "\"\\n\"", ")", "create_count", "=", "0", "BackupRun", "=", "apps", ".", "get_model", "(", "\"backup_app\"", ",", "\"BackupRun\"", ")", "# historical version of BackupRun", "backup_...
manage migrate backup_app 0004_BackupRun_ini_file_20160203_1415
[ "manage", "migrate", "backup_app", "0004_BackupRun_ini_file_20160203_1415" ]
be28666834d2d9e3d8aac1b661cb2d5bd4056c29
https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/backup_app/migrations/0004_BackupRun_ini_file_20160203_1415.py#L9-L27
train
Create config files for backup_app 0004_BackupRun_ini_file_20160203_1415
jedie/PyHardLinkBackup
PyHardLinkBackup/backup_app/migrations/0004_BackupRun_ini_file_20160203_1415.py
reverse_func
def reverse_func(apps, schema_editor): """ manage migrate backup_app 0003_auto_20160127_2002 """ print("\n") remove_count = 0 BackupRun = apps.get_model("backup_app", "BackupRun") backup_runs = BackupRun.objects.all() for backup_run in backup_runs: # Use the origin BackupRun mode...
python
def reverse_func(apps, schema_editor): """ manage migrate backup_app 0003_auto_20160127_2002 """ print("\n") remove_count = 0 BackupRun = apps.get_model("backup_app", "BackupRun") backup_runs = BackupRun.objects.all() for backup_run in backup_runs: # Use the origin BackupRun mode...
[ "def", "reverse_func", "(", "apps", ",", "schema_editor", ")", ":", "print", "(", "\"\\n\"", ")", "remove_count", "=", "0", "BackupRun", "=", "apps", ".", "get_model", "(", "\"backup_app\"", ",", "\"BackupRun\"", ")", "backup_runs", "=", "BackupRun", ".", "o...
manage migrate backup_app 0003_auto_20160127_2002
[ "manage", "migrate", "backup_app", "0003_auto_20160127_2002" ]
be28666834d2d9e3d8aac1b661cb2d5bd4056c29
https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/backup_app/migrations/0004_BackupRun_ini_file_20160203_1415.py#L30-L50
train
Remove all config files from the backup_app folder
SHDShim/pytheos
pytheos/eqn_therm_Speziale.py
speziale_grun
def speziale_grun(v, v0, gamma0, q0, q1): """ calculate Gruneisen parameter for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1:...
python
def speziale_grun(v, v0, gamma0, q0, q1): """ calculate Gruneisen parameter for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1:...
[ "def", "speziale_grun", "(", "v", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", ")", ":", "if", "isuncertainties", "(", "[", "v", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", "]", ")", ":", "gamma", "=", "gamma0", "*", "unp", ".", "exp", ...
calculate Gruneisen parameter for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1: logarithmic derivative of Gruneisen parameter :re...
[ "calculate", "Gruneisen", "parameter", "for", "the", "Speziale", "equation" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Speziale.py#L15-L30
train
calculate Gruneisen parameter for the Speziale equation
SHDShim/pytheos
pytheos/eqn_therm_Speziale.py
speziale_debyetemp
def speziale_debyetemp(v, v0, gamma0, q0, q1, theta0): """ calculate Debye temperature for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter ...
python
def speziale_debyetemp(v, v0, gamma0, q0, q1, theta0): """ calculate Debye temperature for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter ...
[ "def", "speziale_debyetemp", "(", "v", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", ",", "theta0", ")", ":", "if", "isuncertainties", "(", "[", "v", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", ",", "theta0", "]", ")", ":", "f_vu", "=", "...
calculate Debye temperature for the Speziale equation :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1: logarithmic derivative of Gruneisen parameter :para...
[ "calculate", "Debye", "temperature", "for", "the", "Speziale", "equation" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Speziale.py#L33-L54
train
calculate Debye temperature for the Speziale equation
SHDShim/pytheos
pytheos/eqn_therm_Speziale.py
integrate_gamma
def integrate_gamma(v, v0, gamma0, q0, q1, theta0): """ internal function to calculate Debye temperature :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param ...
python
def integrate_gamma(v, v0, gamma0, q0, q1, theta0): """ internal function to calculate Debye temperature :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param ...
[ "def", "integrate_gamma", "(", "v", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", ",", "theta0", ")", ":", "def", "f_integrand", "(", "v", ")", ":", "gamma", "=", "gamma0", "*", "np", ".", "exp", "(", "q0", "/", "q1", "*", "(", "(", "v", "/...
internal function to calculate Debye temperature :param v: unit-cell volume in A^3 :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1: logarithmic derivative of Gruneisen parameter :param the...
[ "internal", "function", "to", "calculate", "Debye", "temperature" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Speziale.py#L57-L74
train
Integrate gamma term at a given temperature
SHDShim/pytheos
pytheos/eqn_therm_Speziale.py
speziale_pth
def speziale_pth(v, temp, v0, gamma0, q0, q1, theta0, n, z, t_ref=300., three_r=3. * constants.R): """ calculate thermal pressure for the Speziale equation :param v: unit-cell volume in A^3 :param temp: temperature in K :param v0: unit-cell volume in A^3 at 1 bar :param gamma0:...
python
def speziale_pth(v, temp, v0, gamma0, q0, q1, theta0, n, z, t_ref=300., three_r=3. * constants.R): """ calculate thermal pressure for the Speziale equation :param v: unit-cell volume in A^3 :param temp: temperature in K :param v0: unit-cell volume in A^3 at 1 bar :param gamma0:...
[ "def", "speziale_pth", "(", "v", ",", "temp", ",", "v0", ",", "gamma0", ",", "q0", ",", "q1", ",", "theta0", ",", "n", ",", "z", ",", "t_ref", "=", "300.", ",", "three_r", "=", "3.", "*", "constants", ".", "R", ")", ":", "v_mol", "=", "vol_uc2m...
calculate thermal pressure for the Speziale equation :param v: unit-cell volume in A^3 :param temp: temperature in K :param v0: unit-cell volume in A^3 at 1 bar :param gamma0: Gruneisen parameter at 1 bar :param q0: logarithmic derivative of Gruneisen parameter :param q1: logarithmic derivative...
[ "calculate", "thermal", "pressure", "for", "the", "Speziale", "equation" ]
be079624405e92fbec60c5ead253eb5917e55237
https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_therm_Speziale.py#L77-L109
train
calculate thermal pressure for the Speziale equation
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.text
def text(self) -> str: """ String representation of the text :return: String representation of the text """ return self.export(output=Mimetypes.PLAINTEXT, exclude=self.default_exclude)
python
def text(self) -> str: """ String representation of the text :return: String representation of the text """ return self.export(output=Mimetypes.PLAINTEXT, exclude=self.default_exclude)
[ "def", "text", "(", "self", ")", "->", "str", ":", "return", "self", ".", "export", "(", "output", "=", "Mimetypes", ".", "PLAINTEXT", ",", "exclude", "=", "self", ".", "default_exclude", ")" ]
String representation of the text :return: String representation of the text
[ "String", "representation", "of", "the", "text" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L62-L67
train
String representation of the text of the current locale.
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.set_creator
def set_creator(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Creator literal value :param value: Value of the creator node :param lang: Language in which the value is """ self.metadata.add(key=DC.creator, value=value, lang=lang)
python
def set_creator(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Creator literal value :param value: Value of the creator node :param lang: Language in which the value is """ self.metadata.add(key=DC.creator, value=value, lang=lang)
[ "def", "set_creator", "(", "self", ",", "value", ":", "Union", "[", "Literal", ",", "Identifier", ",", "str", "]", ",", "lang", ":", "str", "=", "None", ")", ":", "self", ".", "metadata", ".", "add", "(", "key", "=", "DC", ".", "creator", ",", "v...
Set the DC Creator literal value :param value: Value of the creator node :param lang: Language in which the value is
[ "Set", "the", "DC", "Creator", "literal", "value" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L98-L104
train
Set the DC Creator literal value
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.get_title
def get_title(self, lang: str=None) -> Literal: """ Get the title of the object :param lang: Lang to retrieve :return: Title string representation :rtype: Literal """ return self.metadata.get_single(key=DC.title, lang=lang) or \ self.metadata.get_single(key=D...
python
def get_title(self, lang: str=None) -> Literal: """ Get the title of the object :param lang: Lang to retrieve :return: Title string representation :rtype: Literal """ return self.metadata.get_single(key=DC.title, lang=lang) or \ self.metadata.get_single(key=D...
[ "def", "get_title", "(", "self", ",", "lang", ":", "str", "=", "None", ")", "->", "Literal", ":", "return", "self", ".", "metadata", ".", "get_single", "(", "key", "=", "DC", ".", "title", ",", "lang", "=", "lang", ")", "or", "self", ".", "metadata...
Get the title of the object :param lang: Lang to retrieve :return: Title string representation :rtype: Literal
[ "Get", "the", "title", "of", "the", "object" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L106-L114
train
Get the title of the object in the specified language.
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.set_title
def set_title(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Title literal value :param value: Value of the title node :param lang: Language in which the value is """ return self.metadata.add(key=DC.title, value=value, lang=lang)
python
def set_title(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Title literal value :param value: Value of the title node :param lang: Language in which the value is """ return self.metadata.add(key=DC.title, value=value, lang=lang)
[ "def", "set_title", "(", "self", ",", "value", ":", "Union", "[", "Literal", ",", "Identifier", ",", "str", "]", ",", "lang", ":", "str", "=", "None", ")", ":", "return", "self", ".", "metadata", ".", "add", "(", "key", "=", "DC", ".", "title", "...
Set the DC Title literal value :param value: Value of the title node :param lang: Language in which the value is
[ "Set", "the", "DC", "Title", "literal", "value" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L116-L122
train
Set the DC Title literal value
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.get_description
def get_description(self, lang: str=None) -> Literal: """ Get the description of the object :param lang: Lang to retrieve :return: Description string representation :rtype: Literal """ return self.metadata.get_single(key=DC.description, lang=lang)
python
def get_description(self, lang: str=None) -> Literal: """ Get the description of the object :param lang: Lang to retrieve :return: Description string representation :rtype: Literal """ return self.metadata.get_single(key=DC.description, lang=lang)
[ "def", "get_description", "(", "self", ",", "lang", ":", "str", "=", "None", ")", "->", "Literal", ":", "return", "self", ".", "metadata", ".", "get_single", "(", "key", "=", "DC", ".", "description", ",", "lang", "=", "lang", ")" ]
Get the description of the object :param lang: Lang to retrieve :return: Description string representation :rtype: Literal
[ "Get", "the", "description", "of", "the", "object" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L124-L131
train
Get the description of the object
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.set_description
def set_description(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Description literal value :param value: Value of the title node :param lang: Language in which the value is """ return self.metadata.add(key=DC.description, value=value, lang=lang)
python
def set_description(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Description literal value :param value: Value of the title node :param lang: Language in which the value is """ return self.metadata.add(key=DC.description, value=value, lang=lang)
[ "def", "set_description", "(", "self", ",", "value", ":", "Union", "[", "Literal", ",", "Identifier", ",", "str", "]", ",", "lang", ":", "str", "=", "None", ")", ":", "return", "self", ".", "metadata", ".", "add", "(", "key", "=", "DC", ".", "descr...
Set the DC Description literal value :param value: Value of the title node :param lang: Language in which the value is
[ "Set", "the", "DC", "Description", "literal", "value" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L133-L139
train
Set the DC. description literal value
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.set_subject
def set_subject(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Subject literal value :param value: Value of the subject node :param lang: Language in which the value is """ return self.metadata.add(key=DC.subject, value=value, lang=lang)
python
def set_subject(self, value: Union[Literal, Identifier, str], lang: str= None): """ Set the DC Subject literal value :param value: Value of the subject node :param lang: Language in which the value is """ return self.metadata.add(key=DC.subject, value=value, lang=lang)
[ "def", "set_subject", "(", "self", ",", "value", ":", "Union", "[", "Literal", ",", "Identifier", ",", "str", "]", ",", "lang", ":", "str", "=", "None", ")", ":", "return", "self", ".", "metadata", ".", "add", "(", "key", "=", "DC", ".", "subject",...
Set the DC Subject literal value :param value: Value of the subject node :param lang: Language in which the value is
[ "Set", "the", "DC", "Subject", "literal", "value" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L150-L156
train
Set the DC Subject literal value
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
TextualElement.export
def export(self, output: str=None, exclude: List[str]=None, **kwargs): """ Export the collection item in the Mimetype required. ..note:: If current implementation does not have special mimetypes, reuses default_export method :param output: Mimetype to export to (Uses MyCapytain.common.constant...
python
def export(self, output: str=None, exclude: List[str]=None, **kwargs): """ Export the collection item in the Mimetype required. ..note:: If current implementation does not have special mimetypes, reuses default_export method :param output: Mimetype to export to (Uses MyCapytain.common.constant...
[ "def", "export", "(", "self", ",", "output", ":", "str", "=", "None", ",", "exclude", ":", "List", "[", "str", "]", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "Exportable", ".", "export", "(", "self", ",", "output", ",", "exclude", ...
Export the collection item in the Mimetype required. ..note:: If current implementation does not have special mimetypes, reuses default_export method :param output: Mimetype to export to (Uses MyCapytain.common.constants.Mimetypes) :type output: str :param exclude: Information to exclu...
[ "Export", "the", "collection", "item", "in", "the", "Mimetype", "required", "." ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L158-L169
train
Exports the collection item in the Mimetype required.
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
InteractiveTextualNode.childIds
def childIds(self) -> BaseReferenceSet: """ Identifiers of children :return: Identifiers of children """ if self._childIds is None: self._childIds = self.getReffs() return self._childIds
python
def childIds(self) -> BaseReferenceSet: """ Identifiers of children :return: Identifiers of children """ if self._childIds is None: self._childIds = self.getReffs() return self._childIds
[ "def", "childIds", "(", "self", ")", "->", "BaseReferenceSet", ":", "if", "self", ".", "_childIds", "is", "None", ":", "self", ".", "_childIds", "=", "self", ".", "getReffs", "(", ")", "return", "self", ".", "_childIds" ]
Identifiers of children :return: Identifiers of children
[ "Identifiers", "of", "children" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L326-L333
train
Return the Identifiers of children of this object.
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
InteractiveTextualNode.firstId
def firstId(self) -> BaseReference: """ First child's id of current TextualNode """ if self.childIds is not None: if len(self.childIds) > 0: return self.childIds[0] return None else: raise NotImplementedError
python
def firstId(self) -> BaseReference: """ First child's id of current TextualNode """ if self.childIds is not None: if len(self.childIds) > 0: return self.childIds[0] return None else: raise NotImplementedError
[ "def", "firstId", "(", "self", ")", "->", "BaseReference", ":", "if", "self", ".", "childIds", "is", "not", "None", ":", "if", "len", "(", "self", ".", "childIds", ")", ">", "0", ":", "return", "self", ".", "childIds", "[", "0", "]", "return", "Non...
First child's id of current TextualNode
[ "First", "child", "s", "id", "of", "current", "TextualNode" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L336-L344
train
Returns the first child s id of current TextualNode.
Capitains/MyCapytain
MyCapytain/resources/prototypes/text.py
InteractiveTextualNode.lastId
def lastId(self) -> BaseReference: """ Last child's id of current TextualNode """ if self.childIds is not None: if len(self.childIds) > 0: return self.childIds[-1] return None else: raise NotImplementedError
python
def lastId(self) -> BaseReference: """ Last child's id of current TextualNode """ if self.childIds is not None: if len(self.childIds) > 0: return self.childIds[-1] return None else: raise NotImplementedError
[ "def", "lastId", "(", "self", ")", "->", "BaseReference", ":", "if", "self", ".", "childIds", "is", "not", "None", ":", "if", "len", "(", "self", ".", "childIds", ")", ">", "0", ":", "return", "self", ".", "childIds", "[", "-", "1", "]", "return", ...
Last child's id of current TextualNode
[ "Last", "child", "s", "id", "of", "current", "TextualNode" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/text.py#L347-L355
train
Returns the last child s id of current TextualNode.
Capitains/MyCapytain
MyCapytain/resolvers/cts/api.py
HttpCtsResolver.getTextualNode
def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False): """ Retrieve a text node from the API :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :param prevne...
python
def getTextualNode(self, textId, subreference=None, prevnext=False, metadata=False): """ Retrieve a text node from the API :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :param prevne...
[ "def", "getTextualNode", "(", "self", ",", "textId", ",", "subreference", "=", "None", ",", "prevnext", "=", "False", ",", "metadata", "=", "False", ")", ":", "text", "=", "CtsText", "(", "urn", "=", "textId", ",", "retriever", "=", "self", ".", "endpo...
Retrieve a text node from the API :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :param prevnext: Retrieve graph representing previous and next passage :type prevnext: boolean ...
[ "Retrieve", "a", "text", "node", "from", "the", "API" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/api.py#L44-L65
train
Retrieve a text node from the API.
Capitains/MyCapytain
MyCapytain/resolvers/cts/api.py
HttpCtsResolver.getSiblings
def getSiblings(self, textId, subreference): """ Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :return: Tuple of references :rtype: (s...
python
def getSiblings(self, textId, subreference): """ Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :return: Tuple of references :rtype: (s...
[ "def", "getSiblings", "(", "self", ",", "textId", ",", "subreference", ")", ":", "text", "=", "CtsText", "(", "urn", "=", "textId", ",", "retriever", "=", "self", ".", "endpoint", ")", "return", "text", ".", "getPrevNextUrn", "(", "subreference", ")" ]
Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param subreference: CapitainsCtsPassage Reference :type subreference: str :return: Tuple of references :rtype: (str, str)
[ "Retrieve", "the", "siblings", "of", "a", "textual", "node" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/api.py#L67-L81
train
Retrieve the siblings of a textual node.
Capitains/MyCapytain
MyCapytain/resolvers/cts/api.py
HttpCtsResolver.getReffs
def getReffs(self, textId, level=1, subreference=None): """ Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param level: Depth for retrieval :type level: int :param subreference: CapitainsCtsPassage Reference :...
python
def getReffs(self, textId, level=1, subreference=None): """ Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param level: Depth for retrieval :type level: int :param subreference: CapitainsCtsPassage Reference :...
[ "def", "getReffs", "(", "self", ",", "textId", ",", "level", "=", "1", ",", "subreference", "=", "None", ")", ":", "text", "=", "CtsText", "(", "urn", "=", "textId", ",", "retriever", "=", "self", ".", "endpoint", ")", "return", "text", ".", "getReff...
Retrieve the siblings of a textual node :param textId: CtsTextMetadata Identifier :type textId: str :param level: Depth for retrieval :type level: int :param subreference: CapitainsCtsPassage Reference :type subreference: str :return: List of references :...
[ "Retrieve", "the", "siblings", "of", "a", "textual", "node" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/api.py#L83-L99
train
Retrieve the siblings of a textual node.
Capitains/MyCapytain
MyCapytain/resolvers/cts/api.py
HttpCtsResolver.getMetadata
def getMetadata(self, objectId=None, **filters): """ Request metadata about a text or a collection :param objectId: Object Identifier to filter on :type objectId: str :param filters: Kwargs parameters. :type filters: dict :return: Collection """ if object...
python
def getMetadata(self, objectId=None, **filters): """ Request metadata about a text or a collection :param objectId: Object Identifier to filter on :type objectId: str :param filters: Kwargs parameters. :type filters: dict :return: Collection """ if object...
[ "def", "getMetadata", "(", "self", ",", "objectId", "=", "None", ",", "*", "*", "filters", ")", ":", "if", "objectId", "is", "not", "None", ":", "filters", "[", "\"urn\"", "]", "=", "objectId", "ti", "=", "XmlCtsTextInventoryMetadata", ".", "parse", "(",...
Request metadata about a text or a collection :param objectId: Object Identifier to filter on :type objectId: str :param filters: Kwargs parameters. :type filters: dict :return: Collection
[ "Request", "metadata", "about", "a", "text", "or", "a", "collection" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/cts/api.py#L101-L116
train
Request metadata about a text or a collection.
totalgood/twip
twip/util.py
compile_vocab
def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)): """Get the set of words used anywhere in a sequence of documents and assign an integer id This vectorizer is much faster than the scikit-learn version (and only requires low/constant RAM ?). >>> gen = ('...
python
def compile_vocab(docs, limit=1e6, verbose=0, tokenizer=Tokenizer(stem=None, lower=None, strip=None)): """Get the set of words used anywhere in a sequence of documents and assign an integer id This vectorizer is much faster than the scikit-learn version (and only requires low/constant RAM ?). >>> gen = ('...
[ "def", "compile_vocab", "(", "docs", ",", "limit", "=", "1e6", ",", "verbose", "=", "0", ",", "tokenizer", "=", "Tokenizer", "(", "stem", "=", "None", ",", "lower", "=", "None", ",", "strip", "=", "None", ")", ")", ":", "tokenizer", "=", "make_tokeni...
Get the set of words used anywhere in a sequence of documents and assign an integer id This vectorizer is much faster than the scikit-learn version (and only requires low/constant RAM ?). >>> gen = ('label: ' + chr(ord('A') + i % 3)*3 for i in range(11)) >>> d = compile_vocab(gen, verbose=0) >>> d ...
[ "Get", "the", "set", "of", "words", "used", "anywhere", "in", "a", "sequence", "of", "documents", "and", "assign", "an", "integer", "id" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/util.py#L274-L314
train
Compile a sequence of documents into a set of words used anywhere in a sequence of documents and assign an integer id
totalgood/twip
twip/util.py
gen_bows
def gen_bows(docs=None, vocab=None, limit=1e6, verbose=1, tokenizer=Tokenizer): """Generate (yield) a sequence of vectorized documents in gensim format Gensim calls a set of word vectors (BOWs) a `Corpus` Yield: Mapping: mapping between word id and word count (a word vector or BOW) as...
python
def gen_bows(docs=None, vocab=None, limit=1e6, verbose=1, tokenizer=Tokenizer): """Generate (yield) a sequence of vectorized documents in gensim format Gensim calls a set of word vectors (BOWs) a `Corpus` Yield: Mapping: mapping between word id and word count (a word vector or BOW) as...
[ "def", "gen_bows", "(", "docs", "=", "None", ",", "vocab", "=", "None", ",", "limit", "=", "1e6", ",", "verbose", "=", "1", ",", "tokenizer", "=", "Tokenizer", ")", ":", "if", "vocab", "is", "None", ":", "vocab", "=", "compile_vocab", "(", "docs", ...
Generate (yield) a sequence of vectorized documents in gensim format Gensim calls a set of word vectors (BOWs) a `Corpus` Yield: Mapping: mapping between word id and word count (a word vector or BOW) associated with a single document (text string)
[ "Generate", "(", "yield", ")", "a", "sequence", "of", "vectorized", "documents", "in", "gensim", "format" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/util.py#L317-L329
train
Generate a sequence of BOWs in gensim format
totalgood/twip
twip/util.py
gen_file_lines
def gen_file_lines(path, mode='rUb', strip_eol=True, ascii=True, eol='\n'): """Generate a sequence of "documents" from the lines in a file Arguments: path (file or str): path to a file or an open file_obj ready to be read mode (str): file mode to open a file in strip_eol (bool): whether to st...
python
def gen_file_lines(path, mode='rUb', strip_eol=True, ascii=True, eol='\n'): """Generate a sequence of "documents" from the lines in a file Arguments: path (file or str): path to a file or an open file_obj ready to be read mode (str): file mode to open a file in strip_eol (bool): whether to st...
[ "def", "gen_file_lines", "(", "path", ",", "mode", "=", "'rUb'", ",", "strip_eol", "=", "True", ",", "ascii", "=", "True", ",", "eol", "=", "'\\n'", ")", ":", "if", "isinstance", "(", "path", ",", "str", ")", ":", "path", "=", "open", "(", "path", ...
Generate a sequence of "documents" from the lines in a file Arguments: path (file or str): path to a file or an open file_obj ready to be read mode (str): file mode to open a file in strip_eol (bool): whether to strip the EOL char from lines as they are read/generated/yielded ascii (bool): ...
[ "Generate", "a", "sequence", "of", "documents", "from", "the", "lines", "in", "a", "file" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/util.py#L332-L354
train
Generator function that yields a sequence of documents from the lines in a file.
totalgood/twip
twip/util.py
interleave_skip
def interleave_skip(iterables, limit=None): """Like `chain.from_iterable(zip(*iterables))` but doesn't stop at the end of shortest iterable TODO: equivalent to chain.from_iterable(izip_longest(*iterables)) if obj is not None) >>> tuple(interleave_skip(s for s in ('ABCD', 'vwxyz', '12'))) ('A', 'v', '1...
python
def interleave_skip(iterables, limit=None): """Like `chain.from_iterable(zip(*iterables))` but doesn't stop at the end of shortest iterable TODO: equivalent to chain.from_iterable(izip_longest(*iterables)) if obj is not None) >>> tuple(interleave_skip(s for s in ('ABCD', 'vwxyz', '12'))) ('A', 'v', '1...
[ "def", "interleave_skip", "(", "iterables", ",", "limit", "=", "None", ")", ":", "iterators", "=", "map", "(", "iter", ",", "iterables", ")", "while", "iterators", ":", "for", "i", ",", "it", "in", "enumerate", "(", "iterators", ")", ":", "try", ":", ...
Like `chain.from_iterable(zip(*iterables))` but doesn't stop at the end of shortest iterable TODO: equivalent to chain.from_iterable(izip_longest(*iterables)) if obj is not None) >>> tuple(interleave_skip(s for s in ('ABCD', 'vwxyz', '12'))) ('A', 'v', '1', 'B', 'w', '2', 'C', 'x', 'D', 'y', 'z') >>> ...
[ "Like", "chain", ".", "from_iterable", "(", "zip", "(", "*", "iterables", "))", "but", "doesn", "t", "stop", "at", "the", "end", "of", "shortest", "iterable" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/util.py#L390-L407
train
Like chain. from_iterable but doesn t stop at the end of shortest iterable
totalgood/twip
twip/util.py
Tokenizer.span_tokenize_sents
def span_tokenize_sents(self, strings): """ Apply ``self.span_tokenize()`` to each element of ``strings``. I.e.: return iter((self.span_tokenize(s) for s in strings)) :rtype: iter(list(tuple(int, int))) """ raise NotImplementedError("span_tokenizer and span_tokenzie_...
python
def span_tokenize_sents(self, strings): """ Apply ``self.span_tokenize()`` to each element of ``strings``. I.e.: return iter((self.span_tokenize(s) for s in strings)) :rtype: iter(list(tuple(int, int))) """ raise NotImplementedError("span_tokenizer and span_tokenzie_...
[ "def", "span_tokenize_sents", "(", "self", ",", "strings", ")", ":", "raise", "NotImplementedError", "(", "\"span_tokenizer and span_tokenzie_sents not yet implemented. ;)\"", ")", "for", "s", "in", "strings", ":", "yield", "list", "(", "self", ".", "span_tokenize", "...
Apply ``self.span_tokenize()`` to each element of ``strings``. I.e.: return iter((self.span_tokenize(s) for s in strings)) :rtype: iter(list(tuple(int, int)))
[ "Apply", "self", ".", "span_tokenize", "()", "to", "each", "element", "of", "strings", ".", "I", ".", "e", ".", ":", "return", "iter", "((", "self", ".", "span_tokenize", "(", "s", ")", "for", "s", "in", "strings", "))", ":", "rtype", ":", "iter", ...
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/util.py#L177-L185
train
Apply self. span_tokenize to each element of strings. I. e. yield a list of tuples.
Capitains/MyCapytain
MyCapytain/resolvers/utils.py
CollectionDispatcher.inventory
def inventory(self, inventory_name): """ Decorator to register filters for given inventory. For a function "abc", it has the same effect :param inventory_name: :return: .. code-block:: python tic = CtsTextInventoryCollection() latin = CtsTextInventoryMetadata("...
python
def inventory(self, inventory_name): """ Decorator to register filters for given inventory. For a function "abc", it has the same effect :param inventory_name: :return: .. code-block:: python tic = CtsTextInventoryCollection() latin = CtsTextInventoryMetadata("...
[ "def", "inventory", "(", "self", ",", "inventory_name", ")", ":", "def", "decorator", "(", "f", ")", ":", "self", ".", "add", "(", "func", "=", "f", ",", "inventory_name", "=", "inventory_name", ")", "return", "f", "return", "decorator" ]
Decorator to register filters for given inventory. For a function "abc", it has the same effect :param inventory_name: :return: .. code-block:: python tic = CtsTextInventoryCollection() latin = CtsTextInventoryMetadata("urn:perseus:latinLit", parent=tic) la...
[ "Decorator", "to", "register", "filters", "for", "given", "inventory", ".", "For", "a", "function", "abc", "it", "has", "the", "same", "effect" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/utils.py#L45-L68
train
Decorator to register filters for given inventory. For a function abc it has the same effect as f.
Capitains/MyCapytain
MyCapytain/resolvers/utils.py
CollectionDispatcher.dispatch
def dispatch(self, collection, **kwargs): """ Dispatch a collection using internal filters :param collection: Collection object :param kwargs: Additional keyword arguments that could be used by internal filters :return: None :raises: """ for inventory, method in ...
python
def dispatch(self, collection, **kwargs): """ Dispatch a collection using internal filters :param collection: Collection object :param kwargs: Additional keyword arguments that could be used by internal filters :return: None :raises: """ for inventory, method in ...
[ "def", "dispatch", "(", "self", ",", "collection", ",", "*", "*", "kwargs", ")", ":", "for", "inventory", ",", "method", "in", "self", ".", "methods", "[", ":", ":", "-", "1", "]", ":", "if", "method", "(", "collection", ",", "*", "*", "kwargs", ...
Dispatch a collection using internal filters :param collection: Collection object :param kwargs: Additional keyword arguments that could be used by internal filters :return: None :raises:
[ "Dispatch", "a", "collection", "using", "internal", "filters" ]
b11bbf6b6ae141fc02be70471e3fbf6907be6593
https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resolvers/utils.py#L70-L82
train
Dispatch a collection using internal filters
totalgood/twip
twip/nlp.py
generate_tokens
def generate_tokens(doc, regex=CRE_TOKEN, strip=True, nonwords=False): r"""Return a sequence of words or tokens, using a re.match iteratively through the str >>> doc = "John D. Rock\n\nObjective: \n\tSeeking a position as Software --Architect-- / _Project Lead_ that can utilize my expertise and" >>> doc +=...
python
def generate_tokens(doc, regex=CRE_TOKEN, strip=True, nonwords=False): r"""Return a sequence of words or tokens, using a re.match iteratively through the str >>> doc = "John D. Rock\n\nObjective: \n\tSeeking a position as Software --Architect-- / _Project Lead_ that can utilize my expertise and" >>> doc +=...
[ "def", "generate_tokens", "(", "doc", ",", "regex", "=", "CRE_TOKEN", ",", "strip", "=", "True", ",", "nonwords", "=", "False", ")", ":", "if", "isinstance", "(", "regex", ",", "basestring", ")", ":", "regex", "=", "re", ".", "compile", "(", "regex", ...
r"""Return a sequence of words or tokens, using a re.match iteratively through the str >>> doc = "John D. Rock\n\nObjective: \n\tSeeking a position as Software --Architect-- / _Project Lead_ that can utilize my expertise and" >>> doc += " experiences in business application development and proven records in de...
[ "r", "Return", "a", "sequence", "of", "words", "or", "tokens", "using", "a", "re", ".", "match", "iteratively", "through", "the", "str" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L32-L59
train
r Return a sequence of words or tokens from a given doc.
totalgood/twip
twip/nlp.py
financial_float
def financial_float(s, scale_factor=1, typ=float, ignore=FINANCIAL_WHITESPACE, percent_str=PERCENT_SYMBOLS, replace=FINANCIAL_MAPPING, normalize_case=str.lower): """Strip dollar signs and commas from financial numerical string Also...
python
def financial_float(s, scale_factor=1, typ=float, ignore=FINANCIAL_WHITESPACE, percent_str=PERCENT_SYMBOLS, replace=FINANCIAL_MAPPING, normalize_case=str.lower): """Strip dollar signs and commas from financial numerical string Also...
[ "def", "financial_float", "(", "s", ",", "scale_factor", "=", "1", ",", "typ", "=", "float", ",", "ignore", "=", "FINANCIAL_WHITESPACE", ",", "percent_str", "=", "PERCENT_SYMBOLS", ",", "replace", "=", "FINANCIAL_MAPPING", ",", "normalize_case", "=", "str", "....
Strip dollar signs and commas from financial numerical string Also, convert percentages to fractions/factors (generally between 0 and 1.0) >>> [financial_float(x) for x in ("12k Flat", "12,000 flat", "20%", "$10,000 Flat", "15K flat", "null", "None", "", None)] [12000.0, 12000.0, 0.2, 10000.0, 15000.0, 'n...
[ "Strip", "dollar", "signs", "and", "commas", "from", "financial", "numerical", "string" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L62-L90
train
Return a financial number from a string
totalgood/twip
twip/nlp.py
friendly
def friendly(obj): """Make the representation of an object (mainly numbers) more human friendly >>> friendly(1e6) '1M' >>> friendly(-1e3) '-1k' >>> friendly(1.23456789e9) '1.23G' >>> friendly(0) '0' >>> friendly('whatever') 'whatever' """ powers = 'TGMk munp' if ...
python
def friendly(obj): """Make the representation of an object (mainly numbers) more human friendly >>> friendly(1e6) '1M' >>> friendly(-1e3) '-1k' >>> friendly(1.23456789e9) '1.23G' >>> friendly(0) '0' >>> friendly('whatever') 'whatever' """ powers = 'TGMk munp' if ...
[ "def", "friendly", "(", "obj", ")", ":", "powers", "=", "'TGMk munp'", "if", "isinstance", "(", "obj", ",", "(", "float", ",", "int", ",", "long", ")", ")", ":", "sign", "=", "1", "-", "2", "*", "int", "(", "obj", "<", "0", ")", "obj", "=", "...
Make the representation of an object (mainly numbers) more human friendly >>> friendly(1e6) '1M' >>> friendly(-1e3) '-1k' >>> friendly(1.23456789e9) '1.23G' >>> friendly(0) '0' >>> friendly('whatever') 'whatever'
[ "Make", "the", "representation", "of", "an", "object", "(", "mainly", "numbers", ")", "more", "human", "friendly" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L93-L120
train
Make the representation of an object more human friendly.
totalgood/twip
twip/nlp.py
is_invalid_date
def is_invalid_date(d): """Return boolean to indicate whether date is invalid, None if valid, False if not a date >>> import datetime >>> is_invalid_date(datetime.datetime(1970, 1, 1, 0, 0, 1)) >>> is_invalid_date(datetime.datetime(1970, 1, 1)) >>> is_invalid_date(datetime.datetime(1969, 12, 31, 23...
python
def is_invalid_date(d): """Return boolean to indicate whether date is invalid, None if valid, False if not a date >>> import datetime >>> is_invalid_date(datetime.datetime(1970, 1, 1, 0, 0, 1)) >>> is_invalid_date(datetime.datetime(1970, 1, 1)) >>> is_invalid_date(datetime.datetime(1969, 12, 31, 23...
[ "def", "is_invalid_date", "(", "d", ")", ":", "if", "not", "isinstance", "(", "d", ",", "DATE_TYPES", ")", ":", "return", "False", "if", "d", ".", "year", "<", "1970", "or", "d", ".", "year", ">=", "2100", ":", "return", "True" ]
Return boolean to indicate whether date is invalid, None if valid, False if not a date >>> import datetime >>> is_invalid_date(datetime.datetime(1970, 1, 1, 0, 0, 1)) >>> is_invalid_date(datetime.datetime(1970, 1, 1)) >>> is_invalid_date(datetime.datetime(1969, 12, 31, 23, 59, 59, 999999)) True ...
[ "Return", "boolean", "to", "indicate", "whether", "date", "is", "invalid", "None", "if", "valid", "False", "if", "not", "a", "date" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L123-L140
train
Return boolean to indicate whether a date is invalid.
totalgood/twip
twip/nlp.py
nonnull_fields
def nonnull_fields(obj, pretty=True): """Generate `.values()` dict from a table record, removing non-informative values Noninformative values include: date < 1970 date > 2100 False None 0 0.0 '0' '0.0' '0.0000' """ return PrettyDict((k, v) for k, v ...
python
def nonnull_fields(obj, pretty=True): """Generate `.values()` dict from a table record, removing non-informative values Noninformative values include: date < 1970 date > 2100 False None 0 0.0 '0' '0.0' '0.0000' """ return PrettyDict((k, v) for k, v ...
[ "def", "nonnull_fields", "(", "obj", ",", "pretty", "=", "True", ")", ":", "return", "PrettyDict", "(", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "[", "(", "f", ".", "attname", ",", "getattr", "(", "obj", ",", "f", ".", "attname", ",...
Generate `.values()` dict from a table record, removing non-informative values Noninformative values include: date < 1970 date > 2100 False None 0 0.0 '0' '0.0' '0.0000'
[ "Generate", ".", "values", "()", "dict", "from", "a", "table", "record", "removing", "non", "-", "informative", "values" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L143-L162
train
Generate a. values dict from a table record removing non - informative values
totalgood/twip
twip/nlp.py
nltk_download
def nltk_download(name, ignore_errors=True): r"""Like nltk.download, but be quiet about it, and get a room (separate python process) Does some simple whitespace normalization on `name`, but doesn't yet do fuzzy matching Caches the normalized names of packages already attempted, so they aren't re-tried ...
python
def nltk_download(name, ignore_errors=True): r"""Like nltk.download, but be quiet about it, and get a room (separate python process) Does some simple whitespace normalization on `name`, but doesn't yet do fuzzy matching Caches the normalized names of packages already attempted, so they aren't re-tried ...
[ "def", "nltk_download", "(", "name", ",", "ignore_errors", "=", "True", ")", ":", "name", "=", "re", ".", "sub", "(", "r\"[-\\s=+']+\"", ",", "'_'", ",", "name", ".", "lower", "(", ")", ")", "if", "name", "in", "nltk_download", ".", "done", ":", "ret...
r"""Like nltk.download, but be quiet about it, and get a room (separate python process) Does some simple whitespace normalization on `name`, but doesn't yet do fuzzy matching Caches the normalized names of packages already attempted, so they aren't re-tried >>> nltk_download('nonexistent dataset name', ig...
[ "r", "Like", "nltk", ".", "download", "but", "be", "quiet", "about", "it", "and", "get", "a", "room", "(", "separate", "python", "process", ")" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L165-L189
train
Like nltk. download but get a room for the process to download the requested NLTK dataset.
totalgood/twip
twip/nlp.py
make_stemmer
def make_stemmer(stem=None, min_len=3): """Build a nltk.stem.StemmerI instance from regex, named stemmer ('Lancaster', 'Porter', None), or function Arguments: min (int): Dont stem anything short than this. e.g. for min=4 don't stem token "I'm" to "I" >>> make_stemmer() <Stemmer object at ...> ...
python
def make_stemmer(stem=None, min_len=3): """Build a nltk.stem.StemmerI instance from regex, named stemmer ('Lancaster', 'Porter', None), or function Arguments: min (int): Dont stem anything short than this. e.g. for min=4 don't stem token "I'm" to "I" >>> make_stemmer() <Stemmer object at ...> ...
[ "def", "make_stemmer", "(", "stem", "=", "None", ",", "min_len", "=", "3", ")", ":", "if", "not", "stem", "or", "stem", "==", "'passthrough'", ":", "stem", "=", "Stemmer", "(", ")", "# FIXME: this is unnecessary?! and will make the object less picklable?", "stem",...
Build a nltk.stem.StemmerI instance from regex, named stemmer ('Lancaster', 'Porter', None), or function Arguments: min (int): Dont stem anything short than this. e.g. for min=4 don't stem token "I'm" to "I" >>> make_stemmer() <Stemmer object at ...> >>> make_stemmer(str_lower) <function str...
[ "Build", "a", "nltk", ".", "stem", ".", "StemmerI", "instance", "from", "regex", "named", "stemmer", "(", "Lancaster", "Porter", "None", ")", "or", "function" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L247-L294
train
Returns a nltk. stem. StemmerI instance from a regex or a function.
totalgood/twip
twip/nlp.py
make_named_stemmer
def make_named_stemmer(stem=None, min_len=3): """Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>) """...
python
def make_named_stemmer(stem=None, min_len=3): """Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>) """...
[ "def", "make_named_stemmer", "(", "stem", "=", "None", ",", "min_len", "=", "3", ")", ":", "name", ",", "stem", "=", "stringify", "(", "stem", ")", ",", "make_stemmer", "(", "stem", "=", "stem", ",", "min_len", "=", "min_len", ")", "if", "hasattr", "...
Construct a callable object and a string sufficient to reconstruct it later (unpickling) >>> make_named_stemmer('str_lower') ('str_lower', <function str_lower at ...>) >>> make_named_stemmer('Lancaster') ('lancaster', <Stemmer object at ...>)
[ "Construct", "a", "callable", "object", "and", "a", "string", "sufficient", "to", "reconstruct", "it", "later", "(", "unpickling", ")" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L297-L312
train
Construct a callable object and a string sufficient to reconstruct it later
totalgood/twip
twip/nlp.py
vocab_freq
def vocab_freq(docs, limit=1e6, verbose=1, tokenizer=generate_tokens): """Get the set of words used anywhere in a sequence of documents and count occurrences >>> gen = ('label: ' + chr(ord('A') + i % 3)*3 for i in range(11)) >>> vocab_freq(gen, verbose=0) Counter({'label': 11, 'AAA': 4, 'BBB': 4, 'CCC'...
python
def vocab_freq(docs, limit=1e6, verbose=1, tokenizer=generate_tokens): """Get the set of words used anywhere in a sequence of documents and count occurrences >>> gen = ('label: ' + chr(ord('A') + i % 3)*3 for i in range(11)) >>> vocab_freq(gen, verbose=0) Counter({'label': 11, 'AAA': 4, 'BBB': 4, 'CCC'...
[ "def", "vocab_freq", "(", "docs", ",", "limit", "=", "1e6", ",", "verbose", "=", "1", ",", "tokenizer", "=", "generate_tokens", ")", ":", "total", "=", "Counter", "(", ")", "try", ":", "limit", "=", "min", "(", "limit", ",", "docs", ".", "count", "...
Get the set of words used anywhere in a sequence of documents and count occurrences >>> gen = ('label: ' + chr(ord('A') + i % 3)*3 for i in range(11)) >>> vocab_freq(gen, verbose=0) Counter({'label': 11, 'AAA': 4, 'BBB': 4, 'CCC': 3})
[ "Get", "the", "set", "of", "words", "used", "anywhere", "in", "a", "sequence", "of", "documents", "and", "count", "occurrences" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L315-L342
train
Get the set of words used anywhere in a sequence of documents and count occurrences of any occurrance of any occurrence in the document.
totalgood/twip
twip/nlp.py
make_filename
def make_filename(s, allow_whitespace=False, allow_underscore=False, allow_hyphen=False, limit=255, lower=False): r"""Make sure the provided string is a valid filename, and optionally remove whitespace >>> make_filename('Not so great!') 'Notsogreat' >>> make_filename('') 'empty' >>> make_filena...
python
def make_filename(s, allow_whitespace=False, allow_underscore=False, allow_hyphen=False, limit=255, lower=False): r"""Make sure the provided string is a valid filename, and optionally remove whitespace >>> make_filename('Not so great!') 'Notsogreat' >>> make_filename('') 'empty' >>> make_filena...
[ "def", "make_filename", "(", "s", ",", "allow_whitespace", "=", "False", ",", "allow_underscore", "=", "False", ",", "allow_hyphen", "=", "False", ",", "limit", "=", "255", ",", "lower", "=", "False", ")", ":", "s", "=", "stringify", "(", "s", ")", "s"...
r"""Make sure the provided string is a valid filename, and optionally remove whitespace >>> make_filename('Not so great!') 'Notsogreat' >>> make_filename('') 'empty' >>> make_filename('EOF\x00 EOL\n') 'EOFEOL' >>> make_filename('EOF\x00 EOL\n', allow_whitespace=True) 'EOF EOL\n'
[ "r", "Make", "sure", "the", "provided", "string", "is", "a", "valid", "filename", "and", "optionally", "remove", "whitespace" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L380-L404
train
r Make sure the provided string is a valid filename and optionally remove whitespace
totalgood/twip
twip/nlp.py
Stemmer.stem
def stem(self, s): """This should make the Stemmer picklable and unpicklable by not using bound methods""" if self._stemmer is None: return passthrough(s) try: # try the local attribute `stemmer`, a StemmerI instance first # if you use the self.stem method fro...
python
def stem(self, s): """This should make the Stemmer picklable and unpicklable by not using bound methods""" if self._stemmer is None: return passthrough(s) try: # try the local attribute `stemmer`, a StemmerI instance first # if you use the self.stem method fro...
[ "def", "stem", "(", "self", ",", "s", ")", ":", "if", "self", ".", "_stemmer", "is", "None", ":", "return", "passthrough", "(", "s", ")", "try", ":", "# try the local attribute `stemmer`, a StemmerI instance first", "# if you use the self.stem method from an unpickled o...
This should make the Stemmer picklable and unpicklable by not using bound methods
[ "This", "should", "make", "the", "Stemmer", "picklable", "and", "unpicklable", "by", "not", "using", "bound", "methods" ]
5c0411d2acfbe5b421841072814c9152591c03f7
https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/nlp.py#L235-L244
train
Returns the stem of the given string
zhemao/funktown
funktown/vector.py
ImmutableVector.assoc
def assoc(self, index, value): '''Return a new vector with value associated at index. The implicit parameter is not modified.''' newvec = ImmutableVector() newvec.tree = self.tree.assoc(index, value) if index >= self._length: newvec._length = index+1 else: ...
python
def assoc(self, index, value): '''Return a new vector with value associated at index. The implicit parameter is not modified.''' newvec = ImmutableVector() newvec.tree = self.tree.assoc(index, value) if index >= self._length: newvec._length = index+1 else: ...
[ "def", "assoc", "(", "self", ",", "index", ",", "value", ")", ":", "newvec", "=", "ImmutableVector", "(", ")", "newvec", ".", "tree", "=", "self", ".", "tree", ".", "assoc", "(", "index", ",", "value", ")", "if", "index", ">=", "self", ".", "_lengt...
Return a new vector with value associated at index. The implicit parameter is not modified.
[ "Return", "a", "new", "vector", "with", "value", "associated", "at", "index", ".", "The", "implicit", "parameter", "is", "not", "modified", "." ]
8d5c5a8bdad2b85b33b4cea3febd820c2657c375
https://github.com/zhemao/funktown/blob/8d5c5a8bdad2b85b33b4cea3febd820c2657c375/funktown/vector.py#L14-L23
train
Return a new vector with value associated at index. The implicit parameter is not modified.
zhemao/funktown
funktown/vector.py
ImmutableVector.concat
def concat(self, tailvec): '''Returns the result of concatenating tailvec to the implicit parameter''' newvec = ImmutableVector() vallist = [(i + self._length, tailvec[i]) \ for i in range(0, tailvec._length)] newvec.tree = self.tree.multi_assoc(vallist) n...
python
def concat(self, tailvec): '''Returns the result of concatenating tailvec to the implicit parameter''' newvec = ImmutableVector() vallist = [(i + self._length, tailvec[i]) \ for i in range(0, tailvec._length)] newvec.tree = self.tree.multi_assoc(vallist) n...
[ "def", "concat", "(", "self", ",", "tailvec", ")", ":", "newvec", "=", "ImmutableVector", "(", ")", "vallist", "=", "[", "(", "i", "+", "self", ".", "_length", ",", "tailvec", "[", "i", "]", ")", "for", "i", "in", "range", "(", "0", ",", "tailvec...
Returns the result of concatenating tailvec to the implicit parameter
[ "Returns", "the", "result", "of", "concatenating", "tailvec", "to", "the", "implicit", "parameter" ]
8d5c5a8bdad2b85b33b4cea3febd820c2657c375
https://github.com/zhemao/funktown/blob/8d5c5a8bdad2b85b33b4cea3febd820c2657c375/funktown/vector.py#L25-L33
train
Returns the result of concatenating self to the implicit parameter