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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
SHDShim/pytheos | pytheos/eqn_vinet.py | vinet_k_num | def vinet_k_num(v, v0, k0, k0p, precision=1.e-5):
"""
calculate bulk modulus numerically from volume, not pressure
according to test this differs from analytical result by 1.e-5
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference co... | python | def vinet_k_num(v, v0, k0, k0p, precision=1.e-5):
"""
calculate bulk modulus numerically from volume, not pressure
according to test this differs from analytical result by 1.e-5
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference co... | [
"def",
"vinet_k_num",
"(",
"v",
",",
"v0",
",",
"k0",
",",
"k0p",
",",
"precision",
"=",
"1.e-5",
")",
":",
"return",
"-",
"1.",
"*",
"v",
"*",
"vinet_dPdV",
"(",
"v",
",",
"v0",
",",
"k0",
",",
"k0p",
",",
"precision",
"=",
"precision",
")"
] | calculate bulk modulus numerically from volume, not pressure
according to test this differs from analytical result by 1.e-5
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference conditions
:param k0p: pressure derivative of bulk modulus a... | [
"calculate",
"bulk",
"modulus",
"numerically",
"from",
"volume",
"not",
"pressure",
"according",
"to",
"test",
"this",
"differs",
"from",
"analytical",
"result",
"by",
"1",
".",
"e",
"-",
"5"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_vinet.py#L139-L151 | train | calculate bulk modulus numerically from volume not pressure - based |
SHDShim/pytheos | pytheos/eqn_vinet.py | cal_k_vinet | def cal_k_vinet(p, k):
"""
calculate bulk modulus in GPa
:param p: pressure in GPa
:param k: [v0, k0, k0p]
:return: bulk modulus at high pressure in GPa
"""
v = cal_v_vinet(p, k)
return cal_k_vinet_from_v(v, k[0], k[1], k[2]) | python | def cal_k_vinet(p, k):
"""
calculate bulk modulus in GPa
:param p: pressure in GPa
:param k: [v0, k0, k0p]
:return: bulk modulus at high pressure in GPa
"""
v = cal_v_vinet(p, k)
return cal_k_vinet_from_v(v, k[0], k[1], k[2]) | [
"def",
"cal_k_vinet",
"(",
"p",
",",
"k",
")",
":",
"v",
"=",
"cal_v_vinet",
"(",
"p",
",",
"k",
")",
"return",
"cal_k_vinet_from_v",
"(",
"v",
",",
"k",
"[",
"0",
"]",
",",
"k",
"[",
"1",
"]",
",",
"k",
"[",
"2",
"]",
")"
] | calculate bulk modulus in GPa
:param p: pressure in GPa
:param k: [v0, k0, k0p]
:return: bulk modulus at high pressure in GPa | [
"calculate",
"bulk",
"modulus",
"in",
"GPa"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_vinet.py#L154-L163 | train | calculate bulk modulus at high pressure in a single node |
SHDShim/pytheos | pytheos/eqn_vinet.py | cal_k_vinet_from_v | def cal_k_vinet_from_v(v, v0, k0, k0p):
"""
calculate bulk modulus in GPa
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference conditions
:param k0p: pressure derivative of bulk modulus at reference conditions
:return: bulk modul... | python | def cal_k_vinet_from_v(v, v0, k0, k0p):
"""
calculate bulk modulus in GPa
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference conditions
:param k0p: pressure derivative of bulk modulus at reference conditions
:return: bulk modul... | [
"def",
"cal_k_vinet_from_v",
"(",
"v",
",",
"v0",
",",
"k0",
",",
"k0p",
")",
":",
"x",
"=",
"v",
"/",
"v0",
"y",
"=",
"np",
".",
"power",
"(",
"x",
",",
"1.",
"/",
"3.",
")",
"eta",
"=",
"1.5",
"*",
"(",
"k0p",
"-",
"1.",
")",
"k",
"=",
... | calculate bulk modulus in GPa
:param v: unit-cell volume in A^3
:param v0: unit-cell volume in A^3 at 1 bar
:param k0: bulk modulus at reference conditions
:param k0p: pressure derivative of bulk modulus at reference conditions
:return: bulk modulus at high pressure in GPa | [
"calculate",
"bulk",
"modulus",
"in",
"GPa"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_vinet.py#L166-L181 | train | calculate bulk modulus at high pressure in A^3 |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_portals_list | def get_portals_list(self):
""" Method to return a list of Portal names with their id's.
Returns list of tuples as [(id_1, portal_name1), (id_2, portal_name2)]
"""
portal_ids = self.get_domain_portal_ids()
portals = [ (p, self.get_portal_by_id(p)) for p in porta... | python | def get_portals_list(self):
""" Method to return a list of Portal names with their id's.
Returns list of tuples as [(id_1, portal_name1), (id_2, portal_name2)]
"""
portal_ids = self.get_domain_portal_ids()
portals = [ (p, self.get_portal_by_id(p)) for p in porta... | [
"def",
"get_portals_list",
"(",
"self",
")",
":",
"portal_ids",
"=",
"self",
".",
"get_domain_portal_ids",
"(",
")",
"portals",
"=",
"[",
"(",
"p",
",",
"self",
".",
"get_portal_by_id",
"(",
"p",
")",
")",
"for",
"p",
"in",
"portal_ids",
"]",
"return",
... | Method to return a list of Portal names with their id's.
Returns list of tuples as [(id_1, portal_name1), (id_2, portal_name2)] | [
"Method",
"to",
"return",
"a",
"list",
"of",
"Portal",
"names",
"with",
"their",
"id",
"s",
".",
"Returns",
"list",
"of",
"tuples",
"as",
"[",
"(",
"id_1",
"portal_name1",
")",
"(",
"id_2",
"portal_name2",
")",
"]"
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L50-L57 | train | Method to return a list of Portal names with their id s.
Returns list of tuples as [ id_1 id_2 portal_name1 portal_name2 ] |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.user_portals_picker | def user_portals_picker(self):
"""
This function is broken and needs to either be fixed or discarded.
User-Interaction function. Allows user to choose which Portal
to make the active one.
"""
# print("Getting Portals list. This could take a few seconds...")
... | python | def user_portals_picker(self):
"""
This function is broken and needs to either be fixed or discarded.
User-Interaction function. Allows user to choose which Portal
to make the active one.
"""
# print("Getting Portals list. This could take a few seconds...")
... | [
"def",
"user_portals_picker",
"(",
"self",
")",
":",
"# print(\"Getting Portals list. This could take a few seconds...\")",
"portals",
"=",
"self",
".",
"get_portals_list",
"(",
")",
"done",
"=",
"False",
"while",
"not",
"done",
":",
"opts",
"=",
"[",
"(",
"i",
",... | This function is broken and needs to either be fixed or discarded.
User-Interaction function. Allows user to choose which Portal
to make the active one. | [
"This",
"function",
"is",
"broken",
"and",
"needs",
"to",
"either",
"be",
"fixed",
"or",
"discarded",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L59-L88 | train | This function is broken and needs to be fixed and discarded. It is broken and needs to be fixed and needs to be discarded. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_portal_by_name | def get_portal_by_name(self, portal_name):
"""
Set active portal according to the name passed in 'portal_name'.
Returns dictionary of device 'serial_number: rid'
"""
portals = self.get_portals_list()
for p in portals:
# print("Checking {!r}".format(p... | python | def get_portal_by_name(self, portal_name):
"""
Set active portal according to the name passed in 'portal_name'.
Returns dictionary of device 'serial_number: rid'
"""
portals = self.get_portals_list()
for p in portals:
# print("Checking {!r}".format(p... | [
"def",
"get_portal_by_name",
"(",
"self",
",",
"portal_name",
")",
":",
"portals",
"=",
"self",
".",
"get_portals_list",
"(",
")",
"for",
"p",
"in",
"portals",
":",
"# print(\"Checking {!r}\".format(p))",
"if",
"portal_name",
"==",
"p",
"[",
"1",
"]",
":",
"... | Set active portal according to the name passed in 'portal_name'.
Returns dictionary of device 'serial_number: rid' | [
"Set",
"active",
"portal",
"according",
"to",
"the",
"name",
"passed",
"in",
"portal_name",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L91-L111 | train | Get the active portal according to the name passed in portal_name. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.login_to_portal | def login_to_portal(cls,
domain=None,
portal_name=None,
user=None,
credential=None,
use_token=False,
portal_id=None,
# portal_rid=None,
... | python | def login_to_portal(cls,
domain=None,
portal_name=None,
user=None,
credential=None,
use_token=False,
portal_id=None,
# portal_rid=None,
... | [
"def",
"login_to_portal",
"(",
"cls",
",",
"domain",
"=",
"None",
",",
"portal_name",
"=",
"None",
",",
"user",
"=",
"None",
",",
"credential",
"=",
"None",
",",
"use_token",
"=",
"False",
",",
"portal_id",
"=",
"None",
",",
"# portal_rid=None,",
"get_devi... | A classmethod that returns a (token, Portals object) tuple.
This method can be interactive based on the input arguments.
Sets up the Portals object with all the member variables
it needs to make future api calls. It basically just calls
Portals.get_portal_by_name(), bu... | [
"A",
"classmethod",
"that",
"returns",
"a",
"(",
"token",
"Portals",
"object",
")",
"tuple",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L114-L221 | train | This classmethod is used to login to a portal object. It returns a tuple that is used to create a new object and return it. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.add_device_with_name_location_timezone | def add_device_with_name_location_timezone( self,
model,
serial,
name,
location,
... | python | def add_device_with_name_location_timezone( self,
model,
serial,
name,
location,
... | [
"def",
"add_device_with_name_location_timezone",
"(",
"self",
",",
"model",
",",
"serial",
",",
"name",
",",
"location",
",",
"timezone",
")",
":",
"retval",
"=",
"None",
"retval",
"=",
"self",
".",
"add_location_timezone_to_device",
"(",
"self",
".",
"rename_de... | This method wraps the self.add_device() and self.rename_device()
methods.
Returns device object. | [
"This",
"method",
"wraps",
"the",
"self",
".",
"add_device",
"()",
"and",
"self",
".",
"rename_device",
"()",
"methods",
".",
"Returns",
"device",
"object",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L233-L256 | train | This method adds a new device with the specified name location and timezone. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.add_location_timezone_to_device | def add_location_timezone_to_device(self, device_obj, location, timezone):
"""
Returns 'device object' with updated location
http://docs.exosite.com/portals/#update-device
http://docs.exosite.com/portals/#device-object
"""
dictify_device_meta(devi... | python | def add_location_timezone_to_device(self, device_obj, location, timezone):
"""
Returns 'device object' with updated location
http://docs.exosite.com/portals/#update-device
http://docs.exosite.com/portals/#device-object
"""
dictify_device_meta(devi... | [
"def",
"add_location_timezone_to_device",
"(",
"self",
",",
"device_obj",
",",
"location",
",",
"timezone",
")",
":",
"dictify_device_meta",
"(",
"device_obj",
")",
"device_obj",
"[",
"'info'",
"]",
"[",
"'description'",
"]",
"[",
"'meta'",
"]",
"[",
"'location'... | Returns 'device object' with updated location
http://docs.exosite.com/portals/#update-device
http://docs.exosite.com/portals/#device-object | [
"Returns",
"device",
"object",
"with",
"updated",
"location",
"http",
":",
"//",
"docs",
".",
"exosite",
".",
"com",
"/",
"portals",
"/",
"#update",
"-",
"device",
"http",
":",
"//",
"docs",
".",
"exosite",
".",
"com",
"/",
"portals",
"/",
"#device",
"... | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L258-L270 | train | Adds location and timezone to a device object. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.delete_device | def delete_device(self, rid):
"""
Deletes device object with given rid
http://docs.exosite.com/portals/#delete-device
"""
headers = {
'User-Agent': self.user_agent(),
'Content-Type': self.content_type()
}
headers.update... | python | def delete_device(self, rid):
"""
Deletes device object with given rid
http://docs.exosite.com/portals/#delete-device
"""
headers = {
'User-Agent': self.user_agent(),
'Content-Type': self.content_type()
}
headers.update... | [
"def",
"delete_device",
"(",
"self",
",",
"rid",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
"(",
")",
",",
"'Content-Type'",
":",
"self",
".",
"content_type",
"(",
")",
"}",
"headers",
".",
"update",
"(",
"self",
"."... | Deletes device object with given rid
http://docs.exosite.com/portals/#delete-device | [
"Deletes",
"device",
"object",
"with",
"given",
"rid"
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L272-L293 | train | Deletes a device object with given rid |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.list_device_data_sources | def list_device_data_sources(self, device_rid):
"""
List data sources of a portal device with rid 'device_rid'.
http://docs.exosite.com/portals/#list-device-data-source
"""
headers = {
'User-Agent': self.user_agent(),
}
headers.update(self... | python | def list_device_data_sources(self, device_rid):
"""
List data sources of a portal device with rid 'device_rid'.
http://docs.exosite.com/portals/#list-device-data-source
"""
headers = {
'User-Agent': self.user_agent(),
}
headers.update(self... | [
"def",
"list_device_data_sources",
"(",
"self",
",",
"device_rid",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
"(",
")",
",",
"}",
"headers",
".",
"update",
"(",
"self",
".",
"headers",
"(",
")",
")",
"r",
"=",
"reque... | List data sources of a portal device with rid 'device_rid'.
http://docs.exosite.com/portals/#list-device-data-source | [
"List",
"data",
"sources",
"of",
"a",
"portal",
"device",
"with",
"rid",
"device_rid",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L317-L335 | train | List data sources of a portal device with rid device_rid. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_data_source_bulk_request | def get_data_source_bulk_request(self, rids, limit=5):
"""
This grabs each datasource and its multiple datapoints for a particular device.
"""
headers = {
'User-Agent': self.user_agent(),
'Content-Type': self.content_type()
}
headers.up... | python | def get_data_source_bulk_request(self, rids, limit=5):
"""
This grabs each datasource and its multiple datapoints for a particular device.
"""
headers = {
'User-Agent': self.user_agent(),
'Content-Type': self.content_type()
}
headers.up... | [
"def",
"get_data_source_bulk_request",
"(",
"self",
",",
"rids",
",",
"limit",
"=",
"5",
")",
":",
"headers",
"=",
"{",
"'User-Agent'",
":",
"self",
".",
"user_agent",
"(",
")",
",",
"'Content-Type'",
":",
"self",
".",
"content_type",
"(",
")",
"}",
"hea... | This grabs each datasource and its multiple datapoints for a particular device. | [
"This",
"grabs",
"each",
"datasource",
"and",
"its",
"multiple",
"datapoints",
"for",
"a",
"particular",
"device",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L337-L357 | train | This method grabs each datasource and its multiple datapoints for a particular device. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_all_devices_in_portal | def get_all_devices_in_portal(self):
"""
This loops through the get_multiple_devices method 10 rids at a time.
"""
rids = self.get_portal_by_name(
self.portal_name()
)[2][1]['info']['aliases']
# print("RIDS: {0}".format(rids))
... | python | def get_all_devices_in_portal(self):
"""
This loops through the get_multiple_devices method 10 rids at a time.
"""
rids = self.get_portal_by_name(
self.portal_name()
)[2][1]['info']['aliases']
# print("RIDS: {0}".format(rids))
... | [
"def",
"get_all_devices_in_portal",
"(",
"self",
")",
":",
"rids",
"=",
"self",
".",
"get_portal_by_name",
"(",
"self",
".",
"portal_name",
"(",
")",
")",
"[",
"2",
"]",
"[",
"1",
"]",
"[",
"'info'",
"]",
"[",
"'aliases'",
"]",
"# print(\"RIDS: {0}\".forma... | This loops through the get_multiple_devices method 10 rids at a time. | [
"This",
"loops",
"through",
"the",
"get_multiple_devices",
"method",
"10",
"rids",
"at",
"a",
"time",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L366-L390 | train | This method loops through the get_multiple_devices method 10 rids at a time. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.map_aliases_to_device_objects | def map_aliases_to_device_objects(self):
"""
A device object knows its rid, but not its alias.
A portal object knows its device rids and aliases.
This function adds an 'portals_aliases' key to all of the
device objects so they can be sorted by alias.
"""... | python | def map_aliases_to_device_objects(self):
"""
A device object knows its rid, but not its alias.
A portal object knows its device rids and aliases.
This function adds an 'portals_aliases' key to all of the
device objects so they can be sorted by alias.
"""... | [
"def",
"map_aliases_to_device_objects",
"(",
"self",
")",
":",
"all_devices",
"=",
"self",
".",
"get_all_devices_in_portal",
"(",
")",
"for",
"dev_o",
"in",
"all_devices",
":",
"dev_o",
"[",
"'portals_aliases'",
"]",
"=",
"self",
".",
"get_portal_by_name",
"(",
... | A device object knows its rid, but not its alias.
A portal object knows its device rids and aliases.
This function adds an 'portals_aliases' key to all of the
device objects so they can be sorted by alias. | [
"A",
"device",
"object",
"knows",
"its",
"rid",
"but",
"not",
"its",
"alias",
".",
"A",
"portal",
"object",
"knows",
"its",
"device",
"rids",
"and",
"aliases",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L392-L405 | train | This function maps aliases to device objects. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.search_for_devices_by_serial_number | def search_for_devices_by_serial_number(self, sn):
"""
Returns a list of device objects that match the serial number
in param 'sn'.
This will match partial serial numbers.
"""
import re
sn_search = re.compile(sn)
matches = []
for dev... | python | def search_for_devices_by_serial_number(self, sn):
"""
Returns a list of device objects that match the serial number
in param 'sn'.
This will match partial serial numbers.
"""
import re
sn_search = re.compile(sn)
matches = []
for dev... | [
"def",
"search_for_devices_by_serial_number",
"(",
"self",
",",
"sn",
")",
":",
"import",
"re",
"sn_search",
"=",
"re",
".",
"compile",
"(",
"sn",
")",
"matches",
"=",
"[",
"]",
"for",
"dev_o",
"in",
"self",
".",
"get_all_devices_in_portal",
"(",
")",
":",... | Returns a list of device objects that match the serial number
in param 'sn'.
This will match partial serial numbers. | [
"Returns",
"a",
"list",
"of",
"device",
"objects",
"that",
"match",
"the",
"serial",
"number",
"in",
"param",
"sn",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L407-L429 | train | Search for all devices in portal that match the serial number sn. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.print_device_list | def print_device_list(self, device_list=None):
"""
Optional parameter is a list of device objects. If omitted, will
just print all portal devices objects.
"""
dev_list = device_list if device_list is not None else self.get_all_devices_in_portal()
for dev in dev_l... | python | def print_device_list(self, device_list=None):
"""
Optional parameter is a list of device objects. If omitted, will
just print all portal devices objects.
"""
dev_list = device_list if device_list is not None else self.get_all_devices_in_portal()
for dev in dev_l... | [
"def",
"print_device_list",
"(",
"self",
",",
"device_list",
"=",
"None",
")",
":",
"dev_list",
"=",
"device_list",
"if",
"device_list",
"is",
"not",
"None",
"else",
"self",
".",
"get_all_devices_in_portal",
"(",
")",
"for",
"dev",
"in",
"dev_list",
":",
"pr... | Optional parameter is a list of device objects. If omitted, will
just print all portal devices objects. | [
"Optional",
"parameter",
"is",
"a",
"list",
"of",
"device",
"objects",
".",
"If",
"omitted",
"will",
"just",
"print",
"all",
"portal",
"devices",
"objects",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L431-L446 | train | Print the list of portal devices objects. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.print_sorted_device_list | def print_sorted_device_list(self, device_list=None, sort_key='sn'):
"""
Takes in a sort key and prints the device list according to that sort.
Default sorts on serial number.
Current supported sort options are:
- name
- sn
- ... | python | def print_sorted_device_list(self, device_list=None, sort_key='sn'):
"""
Takes in a sort key and prints the device list according to that sort.
Default sorts on serial number.
Current supported sort options are:
- name
- sn
- ... | [
"def",
"print_sorted_device_list",
"(",
"self",
",",
"device_list",
"=",
"None",
",",
"sort_key",
"=",
"'sn'",
")",
":",
"dev_list",
"=",
"device_list",
"if",
"device_list",
"is",
"not",
"None",
"else",
"self",
".",
"get_all_devices_in_portal",
"(",
")",
"sort... | Takes in a sort key and prints the device list according to that sort.
Default sorts on serial number.
Current supported sort options are:
- name
- sn
- portals_aliases
Can take optional device object list. | [
"Takes",
"in",
"a",
"sort",
"key",
"and",
"prints",
"the",
"device",
"list",
"according",
"to",
"that",
"sort",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L448-L489 | train | Print the list of all the devices in the portal. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_user_id_from_email | def get_user_id_from_email(self, email):
""" Uses the get-all-user-accounts Portals API to retrieve the
user-id by supplying an email. """
accts = self.get_all_user_accounts()
for acct in accts:
if acct['email'] == email:
return acct['id']
return None | python | def get_user_id_from_email(self, email):
""" Uses the get-all-user-accounts Portals API to retrieve the
user-id by supplying an email. """
accts = self.get_all_user_accounts()
for acct in accts:
if acct['email'] == email:
return acct['id']
return None | [
"def",
"get_user_id_from_email",
"(",
"self",
",",
"email",
")",
":",
"accts",
"=",
"self",
".",
"get_all_user_accounts",
"(",
")",
"for",
"acct",
"in",
"accts",
":",
"if",
"acct",
"[",
"'email'",
"]",
"==",
"email",
":",
"return",
"acct",
"[",
"'id'",
... | Uses the get-all-user-accounts Portals API to retrieve the
user-id by supplying an email. | [
"Uses",
"the",
"get",
"-",
"all",
"-",
"user",
"-",
"accounts",
"Portals",
"API",
"to",
"retrieve",
"the",
"user",
"-",
"id",
"by",
"supplying",
"an",
"email",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L491-L499 | train | Returns the user - id of the user with the given email address. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_user_permission_from_email | def get_user_permission_from_email(self, email):
""" Returns a user's permissions object when given the user email."""
_id = self.get_user_id_from_email(email)
return self.get_user_permission(_id) | python | def get_user_permission_from_email(self, email):
""" Returns a user's permissions object when given the user email."""
_id = self.get_user_id_from_email(email)
return self.get_user_permission(_id) | [
"def",
"get_user_permission_from_email",
"(",
"self",
",",
"email",
")",
":",
"_id",
"=",
"self",
".",
"get_user_id_from_email",
"(",
"email",
")",
"return",
"self",
".",
"get_user_permission",
"(",
"_id",
")"
] | Returns a user's permissions object when given the user email. | [
"Returns",
"a",
"user",
"s",
"permissions",
"object",
"when",
"given",
"the",
"user",
"email",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L501-L504 | train | Returns a user s permissions object when given the user email. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.add_dplist_permission_for_user_on_portal | def add_dplist_permission_for_user_on_portal(self, user_email, portal_id):
""" Adds the 'd_p_list' permission to a user object when provided
a user_email and portal_id."""
_id = self.get_user_id_from_email(user_email)
print(self.get_user_permission_from_email(user_email))
ret... | python | def add_dplist_permission_for_user_on_portal(self, user_email, portal_id):
""" Adds the 'd_p_list' permission to a user object when provided
a user_email and portal_id."""
_id = self.get_user_id_from_email(user_email)
print(self.get_user_permission_from_email(user_email))
ret... | [
"def",
"add_dplist_permission_for_user_on_portal",
"(",
"self",
",",
"user_email",
",",
"portal_id",
")",
":",
"_id",
"=",
"self",
".",
"get_user_id_from_email",
"(",
"user_email",
")",
"print",
"(",
"self",
".",
"get_user_permission_from_email",
"(",
"user_email",
... | Adds the 'd_p_list' permission to a user object when provided
a user_email and portal_id. | [
"Adds",
"the",
"d_p_list",
"permission",
"to",
"a",
"user",
"object",
"when",
"provided",
"a",
"user_email",
"and",
"portal_id",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L506-L516 | train | Adds the d_p_list permission to a user object when provided
a user_email and portal_id. |
exosite-labs/pyonep | pyonep/portals/__init__.py | Portals.get_portal_cik | def get_portal_cik(self, portal_name):
""" Retrieves portal object according to 'portal_name' and
returns its cik. """
portal = self.get_portal_by_name(portal_name)
cik = portal[2][1]['info']['key']
return cik | python | def get_portal_cik(self, portal_name):
""" Retrieves portal object according to 'portal_name' and
returns its cik. """
portal = self.get_portal_by_name(portal_name)
cik = portal[2][1]['info']['key']
return cik | [
"def",
"get_portal_cik",
"(",
"self",
",",
"portal_name",
")",
":",
"portal",
"=",
"self",
".",
"get_portal_by_name",
"(",
"portal_name",
")",
"cik",
"=",
"portal",
"[",
"2",
"]",
"[",
"1",
"]",
"[",
"'info'",
"]",
"[",
"'key'",
"]",
"return",
"cik"
] | Retrieves portal object according to 'portal_name' and
returns its cik. | [
"Retrieves",
"portal",
"object",
"according",
"to",
"portal_name",
"and",
"returns",
"its",
"cik",
"."
] | d27b621b00688a542e0adcc01f3e3354c05238a1 | https://github.com/exosite-labs/pyonep/blob/d27b621b00688a542e0adcc01f3e3354c05238a1/pyonep/portals/__init__.py#L518-L523 | train | Returns the portal object according to portal_name and
returns its cik. |
chaoss/grimoirelab-cereslib | examples/areas_code.py | init_write_index | def init_write_index(es_write, es_write_index):
"""Initializes ES write index
"""
logging.info("Initializing index: " + es_write_index)
es_write.indices.delete(es_write_index, ignore=[400, 404])
es_write.indices.create(es_write_index, body=MAPPING_GIT) | python | def init_write_index(es_write, es_write_index):
"""Initializes ES write index
"""
logging.info("Initializing index: " + es_write_index)
es_write.indices.delete(es_write_index, ignore=[400, 404])
es_write.indices.create(es_write_index, body=MAPPING_GIT) | [
"def",
"init_write_index",
"(",
"es_write",
",",
"es_write_index",
")",
":",
"logging",
".",
"info",
"(",
"\"Initializing index: \"",
"+",
"es_write_index",
")",
"es_write",
".",
"indices",
".",
"delete",
"(",
"es_write_index",
",",
"ignore",
"=",
"[",
"400",
... | Initializes ES write index | [
"Initializes",
"ES",
"write",
"index"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/examples/areas_code.py#L267-L272 | train | Initializes ES write index |
chaoss/grimoirelab-cereslib | examples/areas_code.py | configure_logging | def configure_logging(info=False, debug=False):
"""Configure logging
The function configures log messages. By default, log messages
are sent to stderr. Set the parameter `debug` to activate the
debug mode.
:param debug: set the debug mode
"""
if info:
logging.basicConfig(level=loggin... | python | def configure_logging(info=False, debug=False):
"""Configure logging
The function configures log messages. By default, log messages
are sent to stderr. Set the parameter `debug` to activate the
debug mode.
:param debug: set the debug mode
"""
if info:
logging.basicConfig(level=loggin... | [
"def",
"configure_logging",
"(",
"info",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"if",
"info",
":",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"format",
"=",
"LOG_FORMAT",
")",
"logging",
".",
"getLogger",
... | Configure logging
The function configures log messages. By default, log messages
are sent to stderr. Set the parameter `debug` to activate the
debug mode.
:param debug: set the debug mode | [
"Configure",
"logging",
"The",
"function",
"configures",
"log",
"messages",
".",
"By",
"default",
"log",
"messages",
"are",
"sent",
"to",
"stderr",
".",
"Set",
"the",
"parameter",
"debug",
"to",
"activate",
"the",
"debug",
"mode",
".",
":",
"param",
"debug",... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/examples/areas_code.py#L385-L406 | train | Configure logging for the current node. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | PairProgramming.enrich | def enrich(self, column1, column2):
""" This class splits those commits where column1 and column2
values are different
:param column1: column to compare to column2
:param column2: column to compare to column1
:type column1: string
:type column2: string
:returns:... | python | def enrich(self, column1, column2):
""" This class splits those commits where column1 and column2
values are different
:param column1: column to compare to column2
:param column2: column to compare to column1
:type column1: string
:type column2: string
:returns:... | [
"def",
"enrich",
"(",
"self",
",",
"column1",
",",
"column2",
")",
":",
"if",
"column1",
"not",
"in",
"self",
".",
"commits",
".",
"columns",
"or",
"column2",
"not",
"in",
"self",
".",
"commits",
".",
"columns",
":",
"return",
"self",
".",
"commits",
... | This class splits those commits where column1 and column2
values are different
:param column1: column to compare to column2
:param column2: column to compare to column1
:type column1: string
:type column2: string
:returns: self.commits with duplicated rows where the val... | [
"This",
"class",
"splits",
"those",
"commits",
"where",
"column1",
"and",
"column2",
"values",
"are",
"different"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L67-L95 | train | This class splits those commits where column1 and column2 values are different from column1
and updates the values in column2
. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | FileType.enrich | def enrich(self, column):
""" This method adds a new column depending on the extension
of the file.
:param column: column where the file path is found
:type column: string
:return: returns the original dataframe with a new column named as
'filetype' that contai... | python | def enrich(self, column):
""" This method adds a new column depending on the extension
of the file.
:param column: column where the file path is found
:type column: string
:return: returns the original dataframe with a new column named as
'filetype' that contai... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
":",
"return",
"self",
".",
"data",
"# Insert a new column with default values",
"self",
".",
"data",
"[",
"\"filetype\"",
"]",
"=",
"'Other'",
"# Insert... | This method adds a new column depending on the extension
of the file.
:param column: column where the file path is found
:type column: string
:return: returns the original dataframe with a new column named as
'filetype' that contains information about its extension
... | [
"This",
"method",
"adds",
"a",
"new",
"column",
"depending",
"on",
"the",
"extension",
"of",
"the",
"file",
"."
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L112-L135 | train | This method adds a new column depending on the extension
of the file. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | FilePath.enrich | def enrich(self, column):
""" This method splits file path in new columns allowing further
filtering on those particular path parts:
* File extension
* File directory name (full path excluding file name)
* File name (excluding directories)
* Path list incl... | python | def enrich(self, column):
""" This method splits file path in new columns allowing further
filtering on those particular path parts:
* File extension
* File directory name (full path excluding file name)
* File name (excluding directories)
* Path list incl... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
":",
"return",
"self",
".",
"data",
"# Insert new columns",
"self",
".",
"data",
"[",
"'file_name'",
"]",
"=",
"self",
".",
"data",
".",
"apply",
... | This method splits file path in new columns allowing further
filtering on those particular path parts:
* File extension
* File directory name (full path excluding file name)
* File name (excluding directories)
* Path list including each directory/file as a separat... | [
"This",
"method",
"splits",
"file",
"path",
"in",
"new",
"columns",
"allowing",
"further",
"filtering",
"on",
"those",
"particular",
"path",
"parts",
":",
"*",
"File",
"extension",
"*",
"File",
"directory",
"name",
"(",
"full",
"path",
"excluding",
"file",
"... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L155-L207 | train | This method enforces the dataframe with the new columns for the given column. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | Projects.enrich | def enrich(self, column, projects):
""" This method adds a new column named as 'project'
that contains information about the associated project
that the event in 'column' belongs to.
:param column: column with information related to the project
:type column: string
:para... | python | def enrich(self, column, projects):
""" This method adds a new column named as 'project'
that contains information about the associated project
that the event in 'column' belongs to.
:param column: column with information related to the project
:type column: string
:para... | [
"def",
"enrich",
"(",
"self",
",",
"column",
",",
"projects",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"self",
".",
"data",
"=",
"pandas",
".",
"merge",
"(",
"self",
".",
"data"... | This method adds a new column named as 'project'
that contains information about the associated project
that the event in 'column' belongs to.
:param column: column with information related to the project
:type column: string
:param projects: information about item - project
... | [
"This",
"method",
"adds",
"a",
"new",
"column",
"named",
"as",
"project",
"that",
"contains",
"information",
"about",
"the",
"associated",
"project",
"that",
"the",
"event",
"in",
"column",
"belongs",
"to",
"."
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L224-L243 | train | This method adds a new column named as project where the associated project is associated with the item with the event in column. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | MessageLogFlag.enrich | def enrich(self, column):
""" This method helps to identify flags in the message log.
As some communities may use the log message for the code
authorship, specifig flags/tags are used to determine
some actions by the authors or reviewers such who is
the author or the reviewer is.... | python | def enrich(self, column):
""" This method helps to identify flags in the message log.
As some communities may use the log message for the code
authorship, specifig flags/tags are used to determine
some actions by the authors or reviewers such who is
the author or the reviewer is.... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"flags_list",
"=",
"[",
"]",
"values_list",
"=",
"[",
"]",
"# Assuming the index of the dataframe i... | This method helps to identify flags in the message log.
As some communities may use the log message for the code
authorship, specifig flags/tags are used to determine
some actions by the authors or reviewers such who is
the author or the reviewer is.
The list of supported flags ... | [
"This",
"method",
"helps",
"to",
"identify",
"flags",
"in",
"the",
"message",
"log",
".",
"As",
"some",
"communities",
"may",
"use",
"the",
"log",
"message",
"for",
"the",
"code",
"authorship",
"specifig",
"flags",
"/",
"tags",
"are",
"used",
"to",
"determ... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L291-L321 | train | This method is used to enrich the data of a single found ArcGIS message log with the flags and values. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | EmailFlag.__parse_flags | def __parse_flags(self, body):
"""Parse flags from a message"""
flags = []
values = []
lines = body.split('\n')
for l in lines:
for name in self.FLAGS_REGEX:
m = re.match(self.FLAGS_REGEX[name], l)
if m:
flags.appen... | python | def __parse_flags(self, body):
"""Parse flags from a message"""
flags = []
values = []
lines = body.split('\n')
for l in lines:
for name in self.FLAGS_REGEX:
m = re.match(self.FLAGS_REGEX[name], l)
if m:
flags.appen... | [
"def",
"__parse_flags",
"(",
"self",
",",
"body",
")",
":",
"flags",
"=",
"[",
"]",
"values",
"=",
"[",
"]",
"lines",
"=",
"body",
".",
"split",
"(",
"'\\n'",
")",
"for",
"l",
"in",
"lines",
":",
"for",
"name",
"in",
"self",
".",
"FLAGS_REGEX",
"... | Parse flags from a message | [
"Parse",
"flags",
"from",
"a",
"message"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L341-L358 | train | Parse flags from a message body |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | SplitEmailDomain.enrich | def enrich(self, column):
""" This enricher returns the same dataframe
with a new column named 'domain'.
That column is the result of splitting the
email address of another column. If there is
not a proper email address an 'unknown'
domain is returned.
:param col... | python | def enrich(self, column):
""" This enricher returns the same dataframe
with a new column named 'domain'.
That column is the result of splitting the
email address of another column. If there is
not a proper email address an 'unknown'
domain is returned.
:param col... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"self",
".",
"data",
"[",
"'domain'",
"]",
"=",
"self",
".",
"data",
"[",
"column",
"]",
... | This enricher returns the same dataframe
with a new column named 'domain'.
That column is the result of splitting the
email address of another column. If there is
not a proper email address an 'unknown'
domain is returned.
:param column: column where the text to analyze ... | [
"This",
"enricher",
"returns",
"the",
"same",
"dataframe",
"with",
"a",
"new",
"column",
"named",
"domain",
".",
"That",
"column",
"is",
"the",
"result",
"of",
"splitting",
"the",
"email",
"address",
"of",
"another",
"column",
".",
"If",
"there",
"is",
"no... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L429-L445 | train | This function returns the same dataframe with a new column named domain. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | ToUTF8.__remove_surrogates | def __remove_surrogates(self, s, method='replace'):
""" Remove surrogates in the specified string
"""
if type(s) == list and len(s) == 1:
if self.__is_surrogate_escaped(s[0]):
return s[0].encode('utf-8', method).decode('utf-8')
else:
retur... | python | def __remove_surrogates(self, s, method='replace'):
""" Remove surrogates in the specified string
"""
if type(s) == list and len(s) == 1:
if self.__is_surrogate_escaped(s[0]):
return s[0].encode('utf-8', method).decode('utf-8')
else:
retur... | [
"def",
"__remove_surrogates",
"(",
"self",
",",
"s",
",",
"method",
"=",
"'replace'",
")",
":",
"if",
"type",
"(",
"s",
")",
"==",
"list",
"and",
"len",
"(",
"s",
")",
"==",
"1",
":",
"if",
"self",
".",
"__is_surrogate_escaped",
"(",
"s",
"[",
"0",... | Remove surrogates in the specified string | [
"Remove",
"surrogates",
"in",
"the",
"specified",
"string"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L452-L467 | train | Removes surrogates in the specified string s |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | ToUTF8.__is_surrogate_escaped | def __is_surrogate_escaped(self, text):
""" Checks if surrogate is escaped
"""
try:
text.encode('utf-8')
except UnicodeEncodeError as e:
if e.reason == 'surrogates not allowed':
return True
return False | python | def __is_surrogate_escaped(self, text):
""" Checks if surrogate is escaped
"""
try:
text.encode('utf-8')
except UnicodeEncodeError as e:
if e.reason == 'surrogates not allowed':
return True
return False | [
"def",
"__is_surrogate_escaped",
"(",
"self",
",",
"text",
")",
":",
"try",
":",
"text",
".",
"encode",
"(",
"'utf-8'",
")",
"except",
"UnicodeEncodeError",
"as",
"e",
":",
"if",
"e",
".",
"reason",
"==",
"'surrogates not allowed'",
":",
"return",
"True",
... | Checks if surrogate is escaped | [
"Checks",
"if",
"surrogate",
"is",
"escaped"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L469-L478 | train | Checks if surrogate is escaped |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | ToUTF8.enrich | def enrich(self, columns):
""" This method convert to utf-8 the provided columns
:param columns: list of columns to convert to
:type columns: list of strings
:return: original dataframe with converted strings
:rtype: pandas.DataFrame
"""
for column in columns:
... | python | def enrich(self, columns):
""" This method convert to utf-8 the provided columns
:param columns: list of columns to convert to
:type columns: list of strings
:return: original dataframe with converted strings
:rtype: pandas.DataFrame
"""
for column in columns:
... | [
"def",
"enrich",
"(",
"self",
",",
"columns",
")",
":",
"for",
"column",
"in",
"columns",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"for",
"column",
"in",
"columns",
":",
"a",
"=",
"s... | This method convert to utf-8 the provided columns
:param columns: list of columns to convert to
:type columns: list of strings
:return: original dataframe with converted strings
:rtype: pandas.DataFrame | [
"This",
"method",
"convert",
"to",
"utf",
"-",
"8",
"the",
"provided",
"columns"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L489-L506 | train | This method converts the provided columns to utf - 8 and returns the original dataframe with converted strings |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | SplitEmail.__parse_addr | def __parse_addr(self, addr):
""" Parse email addresses
"""
from email.utils import parseaddr
value = parseaddr(addr)
return value[0], value[1] | python | def __parse_addr(self, addr):
""" Parse email addresses
"""
from email.utils import parseaddr
value = parseaddr(addr)
return value[0], value[1] | [
"def",
"__parse_addr",
"(",
"self",
",",
"addr",
")",
":",
"from",
"email",
".",
"utils",
"import",
"parseaddr",
"value",
"=",
"parseaddr",
"(",
"addr",
")",
"return",
"value",
"[",
"0",
"]",
",",
"value",
"[",
"1",
"]"
] | Parse email addresses | [
"Parse",
"email",
"addresses"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L515-L522 | train | Parse an email address and return the first and last entry in the list. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | SplitEmail.enrich | def enrich(self, column):
""" This method creates two new columns: user and email.
Those contain the information coming from the usual tuple of
user <email> found in several places like in the mailing lists
or the git repositories commit.
:param column: column to be used for thi... | python | def enrich(self, column):
""" This method creates two new columns: user and email.
Those contain the information coming from the usual tuple of
user <email> found in several places like in the mailing lists
or the git repositories commit.
:param column: column to be used for thi... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"self",
".",
"data",
"[",
"\"user\"",
"]",
",",
"self",
".",
"data",
"[",
"\"email\"",
"]",... | This method creates two new columns: user and email.
Those contain the information coming from the usual tuple of
user <email> found in several places like in the mailing lists
or the git repositories commit.
:param column: column to be used for this parser
:type column: string
... | [
"This",
"method",
"creates",
"two",
"new",
"columns",
":",
"user",
"and",
"email",
".",
"Those",
"contain",
"the",
"information",
"coming",
"from",
"the",
"usual",
"tuple",
"of",
"user",
"<email",
">",
"found",
"in",
"several",
"places",
"like",
"in",
"the... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L533-L551 | train | This method creates two new columns user and email. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | SplitLists.enrich | def enrich(self, columns):
""" This method appends at the end of the dataframe as many
rows as items are found in the list of elemnents in the
provided columns.
This assumes that the length of the lists for the several
specified columns is the same. As an example, for the row A
... | python | def enrich(self, columns):
""" This method appends at the end of the dataframe as many
rows as items are found in the list of elemnents in the
provided columns.
This assumes that the length of the lists for the several
specified columns is the same. As an example, for the row A
... | [
"def",
"enrich",
"(",
"self",
",",
"columns",
")",
":",
"for",
"column",
"in",
"columns",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"# Looking for the rows with columns with lists of more",
"# th... | This method appends at the end of the dataframe as many
rows as items are found in the list of elemnents in the
provided columns.
This assumes that the length of the lists for the several
specified columns is the same. As an example, for the row A
{"C1":"V1", "C2":field1, "C3":f... | [
"This",
"method",
"appends",
"at",
"the",
"end",
"of",
"the",
"dataframe",
"as",
"many",
"rows",
"as",
"items",
"are",
"found",
"in",
"the",
"list",
"of",
"elemnents",
"in",
"the",
"provided",
"columns",
"."
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L569-L622 | train | This method adds the rows of the dataframe to the end of the dataframe as many
rows as items are found in the specified columns. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | MaxMin.enrich | def enrich(self, columns, groupby):
""" This method calculates the maximum and minimum value
of a given set of columns depending on another column.
This is the usual group by clause in SQL.
:param columns: list of columns to apply the max and min values
:param groupby: column us... | python | def enrich(self, columns, groupby):
""" This method calculates the maximum and minimum value
of a given set of columns depending on another column.
This is the usual group by clause in SQL.
:param columns: list of columns to apply the max and min values
:param groupby: column us... | [
"def",
"enrich",
"(",
"self",
",",
"columns",
",",
"groupby",
")",
":",
"for",
"column",
"in",
"columns",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"for",
"column",
"in",
"columns",
":"... | This method calculates the maximum and minimum value
of a given set of columns depending on another column.
This is the usual group by clause in SQL.
:param columns: list of columns to apply the max and min values
:param groupby: column use to calculate the max/min values
:type ... | [
"This",
"method",
"calculates",
"the",
"maximum",
"and",
"minimum",
"value",
"of",
"a",
"given",
"set",
"of",
"columns",
"depending",
"on",
"another",
"column",
".",
"This",
"is",
"the",
"usual",
"group",
"by",
"clause",
"in",
"SQL",
"."
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L640-L665 | train | This method adds the max and min values to the DataFrame. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | Gender.enrich | def enrich(self, column):
""" This method calculates thanks to the genderize.io API the gender
of a given name.
This method initially assumes that for the given
string, only the first word is the one containing the name
eg: Daniel Izquierdo <dizquierdo@bitergia.com>, Daniel woul... | python | def enrich(self, column):
""" This method calculates thanks to the genderize.io API the gender
of a given name.
This method initially assumes that for the given
string, only the first word is the one containing the name
eg: Daniel Izquierdo <dizquierdo@bitergia.com>, Daniel woul... | [
"def",
"enrich",
"(",
"self",
",",
"column",
")",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"splits",
"=",
"self",
".",
"data",
"[",
"column",
"]",
".",
"str",
".",
"split",
"(",
"\... | This method calculates thanks to the genderize.io API the gender
of a given name.
This method initially assumes that for the given
string, only the first word is the one containing the name
eg: Daniel Izquierdo <dizquierdo@bitergia.com>, Daniel would be the name.
If the same cl... | [
"This",
"method",
"calculates",
"thanks",
"to",
"the",
"genderize",
".",
"io",
"API",
"the",
"gender",
"of",
"a",
"given",
"name",
"."
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L710-L772 | train | This method adds gender and probability to the data table. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | TimeDifference.enrich | def enrich(self, column1, column2):
""" This method calculates the difference in seconds between
the 2 columns (column2 - column1)
The final result may provided negative values depending on the values
from column1 and column2.
:param column1: first column. Values in column1... | python | def enrich(self, column1, column2):
""" This method calculates the difference in seconds between
the 2 columns (column2 - column1)
The final result may provided negative values depending on the values
from column1 and column2.
:param column1: first column. Values in column1... | [
"def",
"enrich",
"(",
"self",
",",
"column1",
",",
"column2",
")",
":",
"if",
"column1",
"not",
"in",
"self",
".",
"data",
".",
"columns",
"or",
"column2",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"self",
... | This method calculates the difference in seconds between
the 2 columns (column2 - column1)
The final result may provided negative values depending on the values
from column1 and column2.
:param column1: first column. Values in column1 must be datetime type
:param column2: s... | [
"This",
"method",
"calculates",
"the",
"difference",
"in",
"seconds",
"between",
"the",
"2",
"columns",
"(",
"column2",
"-",
"column1",
")"
] | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L790-L812 | train | This method adds the difference in seconds between column1 and column2 to the dataframe. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | Uuid.enrich | def enrich(self, columns):
""" Merges the original dataframe with corresponding entity uuids based
on the given columns. Also merges other additional information
associated to uuids provided in the uuids dataframe, if any.
:param columns: columns to match for merging
:type colum... | python | def enrich(self, columns):
""" Merges the original dataframe with corresponding entity uuids based
on the given columns. Also merges other additional information
associated to uuids provided in the uuids dataframe, if any.
:param columns: columns to match for merging
:type colum... | [
"def",
"enrich",
"(",
"self",
",",
"columns",
")",
":",
"for",
"column",
"in",
"columns",
":",
"if",
"column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
".",
"data",
"self",
".",
"data",
"=",
"pandas",
".",
"merge",
"... | Merges the original dataframe with corresponding entity uuids based
on the given columns. Also merges other additional information
associated to uuids provided in the uuids dataframe, if any.
:param columns: columns to match for merging
:type column: string array
:return: origi... | [
"Merges",
"the",
"original",
"dataframe",
"with",
"corresponding",
"entity",
"uuids",
"based",
"on",
"the",
"given",
"columns",
".",
"Also",
"merges",
"other",
"additional",
"information",
"associated",
"to",
"uuids",
"provided",
"in",
"the",
"uuids",
"dataframe",... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L850-L870 | train | Merges the original dataframe with corresponding entity uuids based on the given columns. |
chaoss/grimoirelab-cereslib | cereslib/enrich/enrich.py | Onion.enrich | def enrich(self, member_column, events_column):
""" Calculates the onion model for the given set of columns.
This expects two columns as input (typically the author and
the amount of events) and returns a third column with the
role (core, regular, casual) of such community member.
... | python | def enrich(self, member_column, events_column):
""" Calculates the onion model for the given set of columns.
This expects two columns as input (typically the author and
the amount of events) and returns a third column with the
role (core, regular, casual) of such community member.
... | [
"def",
"enrich",
"(",
"self",
",",
"member_column",
",",
"events_column",
")",
":",
"if",
"member_column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
"or",
"events_column",
"not",
"in",
"self",
".",
"data",
".",
"columns",
":",
"return",
"self",
"... | Calculates the onion model for the given set of columns.
This expects two columns as input (typically the author and
the amount of events) and returns a third column with the
role (core, regular, casual) of such community member.
:param columns: columns to match for calculating the onio... | [
"Calculates",
"the",
"onion",
"model",
"for",
"the",
"given",
"set",
"of",
"columns",
".",
"This",
"expects",
"two",
"columns",
"as",
"input",
"(",
"typically",
"the",
"author",
"and",
"the",
"amount",
"of",
"events",
")",
"and",
"returns",
"a",
"third",
... | 5110e6ca490a4f24bec3124286ebf51fd4e08bdd | https://github.com/chaoss/grimoirelab-cereslib/blob/5110e6ca490a4f24bec3124286ebf51fd4e08bdd/cereslib/enrich/enrich.py#L894-L931 | train | This method calculates the onion model for the given set of columns. |
aiidateam/aiida-codtools | aiida_codtools/common/cli.py | echo_utc | def echo_utc(string):
"""Echo the string to standard out, prefixed with the current date and time in UTC format.
:param string: string to echo
"""
from datetime import datetime
click.echo('{} | {}'.format(datetime.utcnow().isoformat(), string)) | python | def echo_utc(string):
"""Echo the string to standard out, prefixed with the current date and time in UTC format.
:param string: string to echo
"""
from datetime import datetime
click.echo('{} | {}'.format(datetime.utcnow().isoformat(), string)) | [
"def",
"echo_utc",
"(",
"string",
")",
":",
"from",
"datetime",
"import",
"datetime",
"click",
".",
"echo",
"(",
"'{} | {}'",
".",
"format",
"(",
"datetime",
".",
"utcnow",
"(",
")",
".",
"isoformat",
"(",
")",
",",
"string",
")",
")"
] | Echo the string to standard out, prefixed with the current date and time in UTC format.
:param string: string to echo | [
"Echo",
"the",
"string",
"to",
"standard",
"out",
"prefixed",
"with",
"the",
"current",
"date",
"and",
"time",
"in",
"UTC",
"format",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/cli.py#L16-L22 | train | Echo the string to standard out prefixed with the current date and time in UTC format. |
aiidateam/aiida-codtools | aiida_codtools/common/cli.py | CliParameters.from_string | def from_string(cls, string):
"""Parse a single string representing all command line parameters."""
if string is None:
string = ''
if not isinstance(string, six.string_types):
raise TypeError('string has to be a string type, got: {}'.format(type(string)))
dictio... | python | def from_string(cls, string):
"""Parse a single string representing all command line parameters."""
if string is None:
string = ''
if not isinstance(string, six.string_types):
raise TypeError('string has to be a string type, got: {}'.format(type(string)))
dictio... | [
"def",
"from_string",
"(",
"cls",
",",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"string",
"=",
"''",
"if",
"not",
"isinstance",
"(",
"string",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'string has to be a string t... | Parse a single string representing all command line parameters. | [
"Parse",
"a",
"single",
"string",
"representing",
"all",
"command",
"line",
"parameters",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/cli.py#L59-L89 | train | Parse a single string representing all command line parameters. |
aiidateam/aiida-codtools | aiida_codtools/common/cli.py | CliParameters.from_dictionary | def from_dictionary(cls, dictionary):
"""Parse a dictionary representing all command line parameters."""
if not isinstance(dictionary, dict):
raise TypeError('dictionary has to be a dict type, got: {}'.format(type(dictionary)))
return cls(dictionary) | python | def from_dictionary(cls, dictionary):
"""Parse a dictionary representing all command line parameters."""
if not isinstance(dictionary, dict):
raise TypeError('dictionary has to be a dict type, got: {}'.format(type(dictionary)))
return cls(dictionary) | [
"def",
"from_dictionary",
"(",
"cls",
",",
"dictionary",
")",
":",
"if",
"not",
"isinstance",
"(",
"dictionary",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'dictionary has to be a dict type, got: {}'",
".",
"format",
"(",
"type",
"(",
"dictionary",
")",
... | Parse a dictionary representing all command line parameters. | [
"Parse",
"a",
"dictionary",
"representing",
"all",
"command",
"line",
"parameters",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/cli.py#L92-L97 | train | Parse a dictionary representing all command line parameters. |
aiidateam/aiida-codtools | aiida_codtools/common/cli.py | CliParameters.get_list | def get_list(self):
"""Return the command line parameters as a list of options, their values and arguments.
:return: list of options, their optional values and arguments
"""
result = []
for key, value in self.parameters.items():
if value is None:
co... | python | def get_list(self):
"""Return the command line parameters as a list of options, their values and arguments.
:return: list of options, their optional values and arguments
"""
result = []
for key, value in self.parameters.items():
if value is None:
co... | [
"def",
"get_list",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"self",
".",
"parameters",
".",
"items",
"(",
")",
":",
"if",
"value",
"is",
"None",
":",
"continue",
"if",
"not",
"isinstance",
"(",
"value",
",",... | Return the command line parameters as a list of options, their values and arguments.
:return: list of options, their optional values and arguments | [
"Return",
"the",
"command",
"line",
"parameters",
"as",
"a",
"list",
"of",
"options",
"their",
"values",
"and",
"arguments",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/cli.py#L99-L134 | train | Return the command line parameters as a list of options their values and arguments. |
aiidateam/aiida-codtools | aiida_codtools/common/cli.py | CliRunner.run | def run(self, daemon=False):
"""Launch the process with the given inputs, by default running in the current interpreter.
:param daemon: boolean, if True, will submit the process instead of running it.
"""
from aiida.engine import launch
# If daemon is True, submit the process a... | python | def run(self, daemon=False):
"""Launch the process with the given inputs, by default running in the current interpreter.
:param daemon: boolean, if True, will submit the process instead of running it.
"""
from aiida.engine import launch
# If daemon is True, submit the process a... | [
"def",
"run",
"(",
"self",
",",
"daemon",
"=",
"False",
")",
":",
"from",
"aiida",
".",
"engine",
"import",
"launch",
"# If daemon is True, submit the process and return",
"if",
"daemon",
":",
"node",
"=",
"launch",
".",
"submit",
"(",
"self",
".",
"process",
... | Launch the process with the given inputs, by default running in the current interpreter.
:param daemon: boolean, if True, will submit the process instead of running it. | [
"Launch",
"the",
"process",
"with",
"the",
"given",
"inputs",
"by",
"default",
"running",
"in",
"the",
"current",
"interpreter",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/common/cli.py#L170-L200 | train | Launch the process with the given inputs by default running in the current interpreter. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | _xpathDict | def _xpathDict(xml, xpath, cls, parent, **kwargs):
""" Returns a default Dict given certain information
:param xml: An xml tree
:type xml: etree
:param xpath: XPath to find children
:type xpath: str
:param cls: Class identifying children
:type cls: inventory.Resource
:param parent: Pare... | python | def _xpathDict(xml, xpath, cls, parent, **kwargs):
""" Returns a default Dict given certain information
:param xml: An xml tree
:type xml: etree
:param xpath: XPath to find children
:type xpath: str
:param cls: Class identifying children
:type cls: inventory.Resource
:param parent: Pare... | [
"def",
"_xpathDict",
"(",
"xml",
",",
"xpath",
",",
"cls",
",",
"parent",
",",
"*",
"*",
"kwargs",
")",
":",
"children",
"=",
"[",
"]",
"for",
"child",
"in",
"xml",
".",
"xpath",
"(",
"xpath",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
":",
"... | Returns a default Dict given certain information
:param xml: An xml tree
:type xml: etree
:param xpath: XPath to find children
:type xpath: str
:param cls: Class identifying children
:type cls: inventory.Resource
:param parent: Parent of object
:type parent: CtsCollection
:rtype: co... | [
"Returns",
"a",
"default",
"Dict",
"given",
"certain",
"information"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L79-L100 | train | Returns a default Dict given certain information. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | _parse_structured_metadata | def _parse_structured_metadata(obj, xml):
""" Parse an XML object for structured metadata
:param obj: Object whose metadata are parsed
:param xml: XML that needs to be parsed
"""
for metadata in xml.xpath("cpt:structured-metadata/*", namespaces=XPATH_NAMESPACES):
tag = metadata.tag
... | python | def _parse_structured_metadata(obj, xml):
""" Parse an XML object for structured metadata
:param obj: Object whose metadata are parsed
:param xml: XML that needs to be parsed
"""
for metadata in xml.xpath("cpt:structured-metadata/*", namespaces=XPATH_NAMESPACES):
tag = metadata.tag
... | [
"def",
"_parse_structured_metadata",
"(",
"obj",
",",
"xml",
")",
":",
"for",
"metadata",
"in",
"xml",
".",
"xpath",
"(",
"\"cpt:structured-metadata/*\"",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
":",
"tag",
"=",
"metadata",
".",
"tag",
"if",
"\"{\"",
... | Parse an XML object for structured metadata
:param obj: Object whose metadata are parsed
:param xml: XML that needs to be parsed | [
"Parse",
"an",
"XML",
"object",
"for",
"structured",
"metadata"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L103-L137 | train | Parses an XML object for structured metadata. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | XmlCtsCitation.ingest | def ingest(cls, resource, element=None, xpath="ti:citation"):
""" Ingest xml to create a citation
:param resource: XML on which to do xpath
:param element: Element where the citation should be stored
:param xpath: XPath to use to retrieve citation
:return: XmlCtsCitation
... | python | def ingest(cls, resource, element=None, xpath="ti:citation"):
""" Ingest xml to create a citation
:param resource: XML on which to do xpath
:param element: Element where the citation should be stored
:param xpath: XPath to use to retrieve citation
:return: XmlCtsCitation
... | [
"def",
"ingest",
"(",
"cls",
",",
"resource",
",",
"element",
"=",
"None",
",",
"xpath",
"=",
"\"ti:citation\"",
")",
":",
"# Reuse of of find citation",
"results",
"=",
"resource",
".",
"xpath",
"(",
"xpath",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
... | Ingest xml to create a citation
:param resource: XML on which to do xpath
:param element: Element where the citation should be stored
:param xpath: XPath to use to retrieve citation
:return: XmlCtsCitation | [
"Ingest",
"xml",
"to",
"create",
"a",
"citation"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L43-L76 | train | Ingest xml to create a citation |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | XmlCtsTextMetadata.parse_metadata | def parse_metadata(cls, obj, xml):
""" Parse a resource to feed the object
:param obj: Obj to set metadata of
:type obj: XmlCtsTextMetadata
:param xml: An xml representation object
:type xml: lxml.etree._Element
"""
for child in xml.xpath("ti:description", names... | python | def parse_metadata(cls, obj, xml):
""" Parse a resource to feed the object
:param obj: Obj to set metadata of
:type obj: XmlCtsTextMetadata
:param xml: An xml representation object
:type xml: lxml.etree._Element
"""
for child in xml.xpath("ti:description", names... | [
"def",
"parse_metadata",
"(",
"cls",
",",
"obj",
",",
"xml",
")",
":",
"for",
"child",
"in",
"xml",
".",
"xpath",
"(",
"\"ti:description\"",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
":",
"lg",
"=",
"child",
".",
"get",
"(",
"\"{http://www.w3.org/XM... | Parse a resource to feed the object
:param obj: Obj to set metadata of
:type obj: XmlCtsTextMetadata
:param xml: An xml representation object
:type xml: lxml.etree._Element | [
"Parse",
"a",
"resource",
"to",
"feed",
"the",
"object"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L156-L192 | train | Parse a resource to feed the object containing the metadata. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | XmlCtsWorkMetadata.parse | def parse(cls, resource, parent=None, _with_children=False):
""" Parse a resource
:param resource: Element rerpresenting a work
:param type: basestring, etree._Element
:param parent: Parent of the object
:type parent: XmlCtsTextgroupMetadata
:param _cls_dict: Dictionary ... | python | def parse(cls, resource, parent=None, _with_children=False):
""" Parse a resource
:param resource: Element rerpresenting a work
:param type: basestring, etree._Element
:param parent: Parent of the object
:type parent: XmlCtsTextgroupMetadata
:param _cls_dict: Dictionary ... | [
"def",
"parse",
"(",
"cls",
",",
"resource",
",",
"parent",
"=",
"None",
",",
"_with_children",
"=",
"False",
")",
":",
"xml",
"=",
"xmlparser",
"(",
"resource",
")",
"o",
"=",
"cls",
"(",
"urn",
"=",
"xml",
".",
"get",
"(",
"\"urn\"",
")",
",",
... | Parse a resource
:param resource: Element rerpresenting a work
:param type: basestring, etree._Element
:param parent: Parent of the object
:type parent: XmlCtsTextgroupMetadata
:param _cls_dict: Dictionary of classes to generate subclasses | [
"Parse",
"a",
"resource"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L256-L296 | train | Parse a resource element and return a new object with the properties set to the properties of the object. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | XmlCtsTextgroupMetadata.parse | def parse(cls, resource, parent=None):
""" Parse a textgroup resource
:param resource: Element representing the textgroup
:param parent: Parent of the textgroup
:param _cls_dict: Dictionary of classes to generate subclasses
"""
xml = xmlparser(resource)
o = cls(u... | python | def parse(cls, resource, parent=None):
""" Parse a textgroup resource
:param resource: Element representing the textgroup
:param parent: Parent of the textgroup
:param _cls_dict: Dictionary of classes to generate subclasses
"""
xml = xmlparser(resource)
o = cls(u... | [
"def",
"parse",
"(",
"cls",
",",
"resource",
",",
"parent",
"=",
"None",
")",
":",
"xml",
"=",
"xmlparser",
"(",
"resource",
")",
"o",
"=",
"cls",
"(",
"urn",
"=",
"xml",
".",
"get",
"(",
"\"urn\"",
")",
",",
"parent",
"=",
"parent",
")",
"for",
... | Parse a textgroup resource
:param resource: Element representing the textgroup
:param parent: Parent of the textgroup
:param _cls_dict: Dictionary of classes to generate subclasses | [
"Parse",
"a",
"textgroup",
"resource"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L305-L324 | train | Parse a textgroup resource and return a new object containing all the classes that are derived from the resource. |
Capitains/MyCapytain | MyCapytain/resources/collections/cts.py | XmlCtsTextInventoryMetadata.parse | def parse(cls, resource):
""" Parse a resource
:param resource: Element representing the text inventory
:param _cls_dict: Dictionary of classes to generate subclasses
"""
xml = xmlparser(resource)
o = cls(name=xml.xpath("//ti:TextInventory", namespaces=XPATH_NAMESPACES)[... | python | def parse(cls, resource):
""" Parse a resource
:param resource: Element representing the text inventory
:param _cls_dict: Dictionary of classes to generate subclasses
"""
xml = xmlparser(resource)
o = cls(name=xml.xpath("//ti:TextInventory", namespaces=XPATH_NAMESPACES)[... | [
"def",
"parse",
"(",
"cls",
",",
"resource",
")",
":",
"xml",
"=",
"xmlparser",
"(",
"resource",
")",
"o",
"=",
"cls",
"(",
"name",
"=",
"xml",
".",
"xpath",
"(",
"\"//ti:TextInventory\"",
",",
"namespaces",
"=",
"XPATH_NAMESPACES",
")",
"[",
"0",
"]",... | Parse a resource
:param resource: Element representing the text inventory
:param _cls_dict: Dictionary of classes to generate subclasses | [
"Parse",
"a",
"resource"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/collections/cts.py#L333-L343 | train | Parse a resource containing the text inventory and return a new object. |
infothrill/python-launchd | example.py | install | def install(label, plist):
'''
Utility function to store a new .plist file and load it
:param label: job label
:param plist: a property list dictionary
'''
fname = launchd.plist.write(label, plist)
launchd.load(fname) | python | def install(label, plist):
'''
Utility function to store a new .plist file and load it
:param label: job label
:param plist: a property list dictionary
'''
fname = launchd.plist.write(label, plist)
launchd.load(fname) | [
"def",
"install",
"(",
"label",
",",
"plist",
")",
":",
"fname",
"=",
"launchd",
".",
"plist",
".",
"write",
"(",
"label",
",",
"plist",
")",
"launchd",
".",
"load",
"(",
"fname",
")"
] | Utility function to store a new .plist file and load it
:param label: job label
:param plist: a property list dictionary | [
"Utility",
"function",
"to",
"store",
"a",
"new",
".",
"plist",
"file",
"and",
"load",
"it"
] | 2cd50579e808851b116f5a26f9b871a32b65ce0e | https://github.com/infothrill/python-launchd/blob/2cd50579e808851b116f5a26f9b871a32b65ce0e/example.py#L12-L20 | train | Utility function to store a new. plist file and load it |
infothrill/python-launchd | example.py | uninstall | def uninstall(label):
'''
Utility function to remove a .plist file and unload it
:param label: job label
'''
if launchd.LaunchdJob(label).exists():
fname = launchd.plist.discover_filename(label)
launchd.unload(fname)
os.unlink(fname) | python | def uninstall(label):
'''
Utility function to remove a .plist file and unload it
:param label: job label
'''
if launchd.LaunchdJob(label).exists():
fname = launchd.plist.discover_filename(label)
launchd.unload(fname)
os.unlink(fname) | [
"def",
"uninstall",
"(",
"label",
")",
":",
"if",
"launchd",
".",
"LaunchdJob",
"(",
"label",
")",
".",
"exists",
"(",
")",
":",
"fname",
"=",
"launchd",
".",
"plist",
".",
"discover_filename",
"(",
"label",
")",
"launchd",
".",
"unload",
"(",
"fname",... | Utility function to remove a .plist file and unload it
:param label: job label | [
"Utility",
"function",
"to",
"remove",
"a",
".",
"plist",
"file",
"and",
"unload",
"it"
] | 2cd50579e808851b116f5a26f9b871a32b65ce0e | https://github.com/infothrill/python-launchd/blob/2cd50579e808851b116f5a26f9b871a32b65ce0e/example.py#L23-L32 | train | Utility function to remove a. plist file and unload it |
Grumbel/procmem | procmem/hexdump.py | write_hex | def write_hex(fout, buf, offset, width=16):
"""Write the content of 'buf' out in a hexdump style
Args:
fout: file object to write to
buf: the buffer to be pretty printed
offset: the starting offset of the buffer
width: how many bytes should be displayed per row
"""
skip... | python | def write_hex(fout, buf, offset, width=16):
"""Write the content of 'buf' out in a hexdump style
Args:
fout: file object to write to
buf: the buffer to be pretty printed
offset: the starting offset of the buffer
width: how many bytes should be displayed per row
"""
skip... | [
"def",
"write_hex",
"(",
"fout",
",",
"buf",
",",
"offset",
",",
"width",
"=",
"16",
")",
":",
"skipped_zeroes",
"=",
"0",
"for",
"i",
",",
"chunk",
"in",
"enumerate",
"(",
"chunk_iter",
"(",
"buf",
",",
"width",
")",
")",
":",
"# zero skipping",
"if... | Write the content of 'buf' out in a hexdump style
Args:
fout: file object to write to
buf: the buffer to be pretty printed
offset: the starting offset of the buffer
width: how many bytes should be displayed per row | [
"Write",
"the",
"content",
"of",
"buf",
"out",
"in",
"a",
"hexdump",
"style"
] | a832a02c4ac79c15f108c72b251820e959a16639 | https://github.com/Grumbel/procmem/blob/a832a02c4ac79c15f108c72b251820e959a16639/procmem/hexdump.py#L26-L68 | train | Writes the content of buf in a hexdump style. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/config.py | edit_ini | def edit_ini(ini_filepath=None):
"""
Open the .ini file with the operating system’s associated editor.
"""
if ini_filepath == None:
ini_filepath = get_ini_filepath()
try:
click.edit(filename=ini_filepath)
except click.exceptions.ClickException as err:
print("Click err: %... | python | def edit_ini(ini_filepath=None):
"""
Open the .ini file with the operating system’s associated editor.
"""
if ini_filepath == None:
ini_filepath = get_ini_filepath()
try:
click.edit(filename=ini_filepath)
except click.exceptions.ClickException as err:
print("Click err: %... | [
"def",
"edit_ini",
"(",
"ini_filepath",
"=",
"None",
")",
":",
"if",
"ini_filepath",
"==",
"None",
":",
"ini_filepath",
"=",
"get_ini_filepath",
"(",
")",
"try",
":",
"click",
".",
"edit",
"(",
"filename",
"=",
"ini_filepath",
")",
"except",
"click",
".",
... | Open the .ini file with the operating system’s associated editor. | [
"Open",
"the",
".",
"ini",
"file",
"with",
"the",
"operating",
"system’s",
"associated",
"editor",
"."
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/config.py#L116-L127 | train | Open the. ini file with the operating system s associated editor. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/config.py | PyHardLinkBackupConfig._read_and_convert | def _read_and_convert(self, filepath, all_values):
"""
if all_values==True: the readed ini file must contain all values
"""
d = get_dict_from_ini(filepath)
result = {}
for key, func in self.ini_converter_dict.items():
if not all_values and key not in d:
... | python | def _read_and_convert(self, filepath, all_values):
"""
if all_values==True: the readed ini file must contain all values
"""
d = get_dict_from_ini(filepath)
result = {}
for key, func in self.ini_converter_dict.items():
if not all_values and key not in d:
... | [
"def",
"_read_and_convert",
"(",
"self",
",",
"filepath",
",",
"all_values",
")",
":",
"d",
"=",
"get_dict_from_ini",
"(",
"filepath",
")",
"result",
"=",
"{",
"}",
"for",
"key",
",",
"func",
"in",
"self",
".",
"ini_converter_dict",
".",
"items",
"(",
")... | if all_values==True: the readed ini file must contain all values | [
"if",
"all_values",
"==",
"True",
":",
"the",
"readed",
"ini",
"file",
"must",
"contain",
"all",
"values"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/config.py#L161-L195 | train | Read and convert the ini file. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/config.py | PyHardLinkBackupConfig._read_config | def _read_config(self):
"""
returns the config as a dict.
"""
default_config_filepath = Path2(os.path.dirname(__file__), DEAFULT_CONFIG_FILENAME)
log.debug("Read defaults from: '%s'" % default_config_filepath)
if not default_config_filepath.is_file():
raise Ru... | python | def _read_config(self):
"""
returns the config as a dict.
"""
default_config_filepath = Path2(os.path.dirname(__file__), DEAFULT_CONFIG_FILENAME)
log.debug("Read defaults from: '%s'" % default_config_filepath)
if not default_config_filepath.is_file():
raise Ru... | [
"def",
"_read_config",
"(",
"self",
")",
":",
"default_config_filepath",
"=",
"Path2",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"DEAFULT_CONFIG_FILENAME",
")",
"log",
".",
"debug",
"(",
"\"Read defaults from: '%s'\"",
"%",
"default_conf... | returns the config as a dict. | [
"returns",
"the",
"config",
"as",
"a",
"dict",
"."
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/config.py#L197-L233 | train | Reads the config file and returns the config as a dict. |
jedie/PyHardLinkBackup | dev/patch_cmd.py | patch | def patch(filepath, debug):
"""
replace 'pause' from windows batch.
Needed for ci.appveyor.com
see: https://github.com/appveyor/ci/issues/596
"""
print("patch 'pause' in %r" % filepath)
with open(filepath, "r") as infile:
origin_content = infile.read()
new_content = origin_conte... | python | def patch(filepath, debug):
"""
replace 'pause' from windows batch.
Needed for ci.appveyor.com
see: https://github.com/appveyor/ci/issues/596
"""
print("patch 'pause' in %r" % filepath)
with open(filepath, "r") as infile:
origin_content = infile.read()
new_content = origin_conte... | [
"def",
"patch",
"(",
"filepath",
",",
"debug",
")",
":",
"print",
"(",
"\"patch 'pause' in %r\"",
"%",
"filepath",
")",
"with",
"open",
"(",
"filepath",
",",
"\"r\"",
")",
"as",
"infile",
":",
"origin_content",
"=",
"infile",
".",
"read",
"(",
")",
"new_... | replace 'pause' from windows batch.
Needed for ci.appveyor.com
see: https://github.com/appveyor/ci/issues/596 | [
"replace",
"pause",
"from",
"windows",
"batch",
".",
"Needed",
"for",
"ci",
".",
"appveyor",
".",
"com",
"see",
":",
"https",
":",
"//",
"github",
".",
"com",
"/",
"appveyor",
"/",
"ci",
"/",
"issues",
"/",
"596"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/dev/patch_cmd.py#L3-L25 | train | patch the file at filepath with the new content |
Capitains/MyCapytain | MyCapytain/common/constants.py | bind_graph | def bind_graph(graph=None):
""" Bind a graph with generic MyCapytain prefixes
:param graph: Graph (Optional)
:return: Bound graph
"""
if graph is None:
graph = Graph()
for prefix, ns in GRAPH_BINDINGS.items():
graph.bind(prefix, ns, True)
return graph | python | def bind_graph(graph=None):
""" Bind a graph with generic MyCapytain prefixes
:param graph: Graph (Optional)
:return: Bound graph
"""
if graph is None:
graph = Graph()
for prefix, ns in GRAPH_BINDINGS.items():
graph.bind(prefix, ns, True)
return graph | [
"def",
"bind_graph",
"(",
"graph",
"=",
"None",
")",
":",
"if",
"graph",
"is",
"None",
":",
"graph",
"=",
"Graph",
"(",
")",
"for",
"prefix",
",",
"ns",
"in",
"GRAPH_BINDINGS",
".",
"items",
"(",
")",
":",
"graph",
".",
"bind",
"(",
"prefix",
",",
... | Bind a graph with generic MyCapytain prefixes
:param graph: Graph (Optional)
:return: Bound graph | [
"Bind",
"a",
"graph",
"with",
"generic",
"MyCapytain",
"prefixes"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/constants.py#L123-L133 | train | Bind a graph with generic MyCapytain prefixes |
thiagokokada/livedumper | src/livedumper/common.py | yes_no_query | def yes_no_query(question):
"""Ask the user *question* for 'yes' or 'no'; ask again until user
inputs a valid option.
Returns:
'True' if user answered 'y', 'yes', 't', 'true', 'on' or '1'.
'False' if user answered 'n', 'no', 'f', 'false', 'off' or '0'.
"""
print("{} (y/n)".format(question)... | python | def yes_no_query(question):
"""Ask the user *question* for 'yes' or 'no'; ask again until user
inputs a valid option.
Returns:
'True' if user answered 'y', 'yes', 't', 'true', 'on' or '1'.
'False' if user answered 'n', 'no', 'f', 'false', 'off' or '0'.
"""
print("{} (y/n)".format(question)... | [
"def",
"yes_no_query",
"(",
"question",
")",
":",
"print",
"(",
"\"{} (y/n)\"",
".",
"format",
"(",
"question",
")",
",",
"end",
"=",
"\" \"",
")",
",",
"while",
"True",
":",
"try",
":",
"return",
"strtobool",
"(",
"input",
"(",
")",
".",
"lower",
"(... | Ask the user *question* for 'yes' or 'no'; ask again until user
inputs a valid option.
Returns:
'True' if user answered 'y', 'yes', 't', 'true', 'on' or '1'.
'False' if user answered 'n', 'no', 'f', 'false', 'off' or '0'. | [
"Ask",
"the",
"user",
"*",
"question",
"*",
"for",
"yes",
"or",
"no",
";",
"ask",
"again",
"until",
"user",
"inputs",
"a",
"valid",
"option",
"."
] | f6441283269b4a602cafea3be5cda9446fc64005 | https://github.com/thiagokokada/livedumper/blob/f6441283269b4a602cafea3be5cda9446fc64005/src/livedumper/common.py#L16-L30 | train | Ask the user for yes or no ; ask again until user answers a valid option. |
thiagokokada/livedumper | src/livedumper/common.py | ask_overwrite | def ask_overwrite(dest):
"""Check if file *dest* exists. If 'True', asks if the user wants
to overwrite it (just remove the file for later overwrite).
"""
msg = "File '{}' already exists. Overwrite file?".format(dest)
if os.path.exists(dest):
if yes_no_query(msg):
os.remove(dest... | python | def ask_overwrite(dest):
"""Check if file *dest* exists. If 'True', asks if the user wants
to overwrite it (just remove the file for later overwrite).
"""
msg = "File '{}' already exists. Overwrite file?".format(dest)
if os.path.exists(dest):
if yes_no_query(msg):
os.remove(dest... | [
"def",
"ask_overwrite",
"(",
"dest",
")",
":",
"msg",
"=",
"\"File '{}' already exists. Overwrite file?\"",
".",
"format",
"(",
"dest",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"dest",
")",
":",
"if",
"yes_no_query",
"(",
"msg",
")",
":",
"os",
... | Check if file *dest* exists. If 'True', asks if the user wants
to overwrite it (just remove the file for later overwrite). | [
"Check",
"if",
"file",
"*",
"dest",
"*",
"exists",
".",
"If",
"True",
"asks",
"if",
"the",
"user",
"wants",
"to",
"overwrite",
"it",
"(",
"just",
"remove",
"the",
"file",
"for",
"later",
"overwrite",
")",
"."
] | f6441283269b4a602cafea3be5cda9446fc64005 | https://github.com/thiagokokada/livedumper/blob/f6441283269b4a602cafea3be5cda9446fc64005/src/livedumper/common.py#L33-L43 | train | Check if file *dest* exists. If True asks if the user wants to overwrite it. If False exit the program. |
SHDShim/pytheos | pytheos/eqn_electronic.py | zharkov_pel | def zharkov_pel(v, temp, v0, e0, g, n, z, t_ref=300.,
three_r=3. * constants.R):
"""
calculate electronic contributions in pressure for the Zharkov equation
the equation can be found in Sokolova and Dorogokupets 2013
:param v: unit-cell volume in A^3
:param temp: temperature in K
... | python | def zharkov_pel(v, temp, v0, e0, g, n, z, t_ref=300.,
three_r=3. * constants.R):
"""
calculate electronic contributions in pressure for the Zharkov equation
the equation can be found in Sokolova and Dorogokupets 2013
:param v: unit-cell volume in A^3
:param temp: temperature in K
... | [
"def",
"zharkov_pel",
"(",
"v",
",",
"temp",
",",
"v0",
",",
"e0",
",",
"g",
",",
"n",
",",
"z",
",",
"t_ref",
"=",
"300.",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
")",
":",
"v_mol",
"=",
"vol_uc2mol",
"(",
"v",
",",
"z",
")",
... | calculate electronic contributions in pressure for the Zharkov equation
the equation can be found in Sokolova and Dorogokupets 2013
: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 e0: parameter in K-1 for the Zharkov equation
:p... | [
"calculate",
"electronic",
"contributions",
"in",
"pressure",
"for",
"the",
"Zharkov",
"equation",
"the",
"equation",
"can",
"be",
"found",
"in",
"Sokolova",
"and",
"Dorogokupets",
"2013"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_electronic.py#L6-L30 | train | calculate electronic contributions in pressure for Zharkov equation |
SHDShim/pytheos | pytheos/eqn_electronic.py | tsuchiya_pel | def tsuchiya_pel(v, temp, v0, a, b, c, d, n, z, three_r=3. * constants.R,
t_ref=300.):
"""
calculate electronic contributions in pressure for the Tsuchiya 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... | python | def tsuchiya_pel(v, temp, v0, a, b, c, d, n, z, three_r=3. * constants.R,
t_ref=300.):
"""
calculate electronic contributions in pressure for the Tsuchiya 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... | [
"def",
"tsuchiya_pel",
"(",
"v",
",",
"temp",
",",
"v0",
",",
"a",
",",
"b",
",",
"c",
",",
"d",
",",
"n",
",",
"z",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
",",
"t_ref",
"=",
"300.",
")",
":",
"def",
"f",
"(",
"temp",
")",
... | calculate electronic contributions in pressure for the Tsuchiya 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 a: parameter for the Tsuchiya equation
:param b: parameter for the Tsuchiya equation
:param c: parameter fo... | [
"calculate",
"electronic",
"contributions",
"in",
"pressure",
"for",
"the",
"Tsuchiya",
"equation"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_electronic.py#L33-L55 | train | calculate electronic contributions in pressure for the Tsuchiya equation |
aiidateam/aiida-codtools | aiida_codtools/calculations/cif_base.py | CifBaseCalculation._validate_resources | def _validate_resources(self):
"""Validate the resources defined in the options."""
resources = self.options.resources
for key in ['num_machines', 'num_mpiprocs_per_machine', 'tot_num_mpiprocs']:
if key in resources and resources[key] != 1:
raise exceptions.FeatureNo... | python | def _validate_resources(self):
"""Validate the resources defined in the options."""
resources = self.options.resources
for key in ['num_machines', 'num_mpiprocs_per_machine', 'tot_num_mpiprocs']:
if key in resources and resources[key] != 1:
raise exceptions.FeatureNo... | [
"def",
"_validate_resources",
"(",
"self",
")",
":",
"resources",
"=",
"self",
".",
"options",
".",
"resources",
"for",
"key",
"in",
"[",
"'num_machines'",
",",
"'num_mpiprocs_per_machine'",
",",
"'tot_num_mpiprocs'",
"]",
":",
"if",
"key",
"in",
"resources",
... | Validate the resources defined in the options. | [
"Validate",
"the",
"resources",
"defined",
"in",
"the",
"options",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/calculations/cif_base.py#L58-L66 | train | Validate the resources defined in the options. |
aiidateam/aiida-codtools | aiida_codtools/calculations/cif_base.py | CifBaseCalculation.prepare_for_submission | def prepare_for_submission(self, folder):
"""This method is called prior to job submission with a set of calculation input nodes.
The inputs will be validated and sanitized, after which the necessary input files will be written to disk in a
temporary folder. A CalcInfo instance will be returned... | python | def prepare_for_submission(self, folder):
"""This method is called prior to job submission with a set of calculation input nodes.
The inputs will be validated and sanitized, after which the necessary input files will be written to disk in a
temporary folder. A CalcInfo instance will be returned... | [
"def",
"prepare_for_submission",
"(",
"self",
",",
"folder",
")",
":",
"from",
"aiida_codtools",
".",
"common",
".",
"cli",
"import",
"CliParameters",
"try",
":",
"parameters",
"=",
"self",
".",
"inputs",
".",
"parameters",
".",
"get_dict",
"(",
")",
"except... | This method is called prior to job submission with a set of calculation input nodes.
The inputs will be validated and sanitized, after which the necessary input files will be written to disk in a
temporary folder. A CalcInfo instance will be returned that contains lists of files that need to be copied ... | [
"This",
"method",
"is",
"called",
"prior",
"to",
"job",
"submission",
"with",
"a",
"set",
"of",
"calculation",
"input",
"nodes",
"."
] | da5e4259b7a2e86cf0cc3f997e11dd36d445fa94 | https://github.com/aiidateam/aiida-codtools/blob/da5e4259b7a2e86cf0cc3f997e11dd36d445fa94/aiida_codtools/calculations/cif_base.py#L68-L104 | train | This method is called before the job submission with a set of calculation input nodes. This method is called before the job submission with a set of calculation input nodes. |
SHDShim/pytheos | pytheos/eqn_hugoniot.py | hugoniot_p | def hugoniot_p(rho, rho0, c0, s):
"""
calculate pressure along a Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:return: pressure in GPa
"""
eta = 1. - (rho0 / rho)
Ph = r... | python | def hugoniot_p(rho, rho0, c0, s):
"""
calculate pressure along a Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:return: pressure in GPa
"""
eta = 1. - (rho0 / rho)
Ph = r... | [
"def",
"hugoniot_p",
"(",
"rho",
",",
"rho0",
",",
"c0",
",",
"s",
")",
":",
"eta",
"=",
"1.",
"-",
"(",
"rho0",
"/",
"rho",
")",
"Ph",
"=",
"rho0",
"*",
"c0",
"*",
"c0",
"*",
"eta",
"/",
"np",
".",
"power",
"(",
"(",
"1.",
"-",
"s",
"*",... | calculate pressure along a Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:return: pressure in GPa | [
"calculate",
"pressure",
"along",
"a",
"Hugoniot"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L10-L22 | train | calculate pressure along a Hugoniot
|
SHDShim/pytheos | pytheos/eqn_hugoniot.py | _dT_h_delta | def _dT_h_delta(T_in_kK, eta, k, threenk, c_v):
"""
internal function for calculation of temperature along a Hugoniot
:param T_in_kK: temperature in kK scale, see Jamieson for detail
:param eta: = 1 - rho0/rho
:param k: = [rho0, c0, s, gamma0, q, theta0]
:param threenk: see the definition in Ja... | python | def _dT_h_delta(T_in_kK, eta, k, threenk, c_v):
"""
internal function for calculation of temperature along a Hugoniot
:param T_in_kK: temperature in kK scale, see Jamieson for detail
:param eta: = 1 - rho0/rho
:param k: = [rho0, c0, s, gamma0, q, theta0]
:param threenk: see the definition in Ja... | [
"def",
"_dT_h_delta",
"(",
"T_in_kK",
",",
"eta",
",",
"k",
",",
"threenk",
",",
"c_v",
")",
":",
"rho0",
"=",
"k",
"[",
"0",
"]",
"# g/m^3",
"gamma0",
"=",
"k",
"[",
"3",
"]",
"# no unit",
"q",
"=",
"k",
"[",
"4",
"]",
"# no unit",
"theta0_in_kK... | internal function for calculation of temperature along a Hugoniot
:param T_in_kK: temperature in kK scale, see Jamieson for detail
:param eta: = 1 - rho0/rho
:param k: = [rho0, c0, s, gamma0, q, theta0]
:param threenk: see the definition in Jamieson 1983,
it is a correction term mostly for Jami... | [
"internal",
"function",
"for",
"calculation",
"of",
"temperature",
"along",
"a",
"Hugoniot"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L25-L60 | train | internal function for calculation of temperature along a Hugoniot and return the Hugoniot derivative of the temperature in kK. |
SHDShim/pytheos | pytheos/eqn_hugoniot.py | hugoniot_t_single | def hugoniot_t_single(rho, rho0, c0, s, gamma0, q, theta0, n, mass,
three_r=3. * constants.R, t_ref=300., c_v=0.):
"""
internal function to calculate pressure along Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in k... | python | def hugoniot_t_single(rho, rho0, c0, s, gamma0, q, theta0, n, mass,
three_r=3. * constants.R, t_ref=300., c_v=0.):
"""
internal function to calculate pressure along Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in k... | [
"def",
"hugoniot_t_single",
"(",
"rho",
",",
"rho0",
",",
"c0",
",",
"s",
",",
"gamma0",
",",
"q",
",",
"theta0",
",",
"n",
",",
"mass",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
",",
"t_ref",
"=",
"300.",
",",
"c_v",
"=",
"0.",
")... | internal function to calculate pressure along Hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen para... | [
"internal",
"function",
"to",
"calculate",
"pressure",
"along",
"Hugoniot"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L63-L91 | train | internal function to calculate pressure along Hugoniot |
SHDShim/pytheos | pytheos/eqn_hugoniot.py | hugoniot_t | def hugoniot_t(rho, rho0, c0, s, gamma0, q, theta0, n, mass,
three_r=3. * constants.R, t_ref=300., c_v=0.):
"""
calculate temperature along a hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the... | python | def hugoniot_t(rho, rho0, c0, s, gamma0, q, theta0, n, mass,
three_r=3. * constants.R, t_ref=300., c_v=0.):
"""
calculate temperature along a hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the... | [
"def",
"hugoniot_t",
"(",
"rho",
",",
"rho0",
",",
"c0",
",",
"s",
",",
"gamma0",
",",
"q",
",",
"theta0",
",",
"n",
",",
"mass",
",",
"three_r",
"=",
"3.",
"*",
"constants",
".",
"R",
",",
"t_ref",
"=",
"300.",
",",
"c_v",
"=",
"0.",
")",
":... | calculate temperature along a hugoniot
:param rho: density in g/cm^3
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param gamma0: Gruneisen parameter at 1 bar
:param q: logarithmic derivative of Gruneisen parameter
:param... | [
"calculate",
"temperature",
"along",
"a",
"hugoniot"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L94-L121 | train | calculate temperature along a hugoniot |
SHDShim/pytheos | pytheos/eqn_hugoniot.py | hugoniot_rho | def hugoniot_rho(p, rho0, c0, s, min_strain=0.01):
"""
calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v/v0 val... | python | def hugoniot_rho(p, rho0, c0, s, min_strain=0.01):
"""
calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v/v0 val... | [
"def",
"hugoniot_rho",
"(",
"p",
",",
"rho0",
",",
"c0",
",",
"s",
",",
"min_strain",
"=",
"0.01",
")",
":",
"if",
"isuncertainties",
"(",
"[",
"p",
",",
"rho0",
",",
"c0",
",",
"s",
"]",
")",
":",
"f_u",
"=",
"np",
".",
"vectorize",
"(",
"uct"... | calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v/v0 value to search volume for
:return: density in g/cm^3
:not... | [
"calculate",
"density",
"in",
"g",
"/",
"cm^3",
"from",
"a",
"hugoniot",
"curve"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L125-L143 | train | calculate density in g / cm^3 from a hugoniot curve |
SHDShim/pytheos | pytheos/eqn_hugoniot.py | hugoniot_rho_single | def hugoniot_rho_single(p, rho0, c0, s, min_strain=0.01):
"""
calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v... | python | def hugoniot_rho_single(p, rho0, c0, s, min_strain=0.01):
"""
calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v... | [
"def",
"hugoniot_rho_single",
"(",
"p",
",",
"rho0",
",",
"c0",
",",
"s",
",",
"min_strain",
"=",
"0.01",
")",
":",
"if",
"p",
"<=",
"1.e-5",
":",
"return",
"rho0",
"def",
"f_diff",
"(",
"rho",
")",
":",
"return",
"hugoniot_p",
"(",
"rho",
",",
"rh... | calculate density in g/cm^3 from a hugoniot curve
:param p: pressure in GPa
:param rho0: density at 1 bar in g/cm^3
:param c0: velocity at 1 bar in km/s
:param s: slope of the velocity change
:param min_strain: defining minimum v/v0 value to search volume for
:return: density in g/cm^3 | [
"calculate",
"density",
"in",
"g",
"/",
"cm^3",
"from",
"a",
"hugoniot",
"curve"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/eqn_hugoniot.py#L146-L163 | train | calculate density in g / cm^3 from a hugoniot curve |
iduartgomez/rustypy | src/rustypy/rswrapper/pytypes.py | PyString.to_str | def to_str(self):
"""Consumes the wrapper and returns a Python string.
Afterwards is not necessary to destruct it as it has already
been consumed."""
val = c_backend.pystring_get_str(self._ptr)
delattr(self, '_ptr')
setattr(self, 'to_str', _dangling_pointer)
retur... | python | def to_str(self):
"""Consumes the wrapper and returns a Python string.
Afterwards is not necessary to destruct it as it has already
been consumed."""
val = c_backend.pystring_get_str(self._ptr)
delattr(self, '_ptr')
setattr(self, 'to_str', _dangling_pointer)
retur... | [
"def",
"to_str",
"(",
"self",
")",
":",
"val",
"=",
"c_backend",
".",
"pystring_get_str",
"(",
"self",
".",
"_ptr",
")",
"delattr",
"(",
"self",
",",
"'_ptr'",
")",
"setattr",
"(",
"self",
",",
"'to_str'",
",",
"_dangling_pointer",
")",
"return",
"val",
... | Consumes the wrapper and returns a Python string.
Afterwards is not necessary to destruct it as it has already
been consumed. | [
"Consumes",
"the",
"wrapper",
"and",
"returns",
"a",
"Python",
"string",
".",
"Afterwards",
"is",
"not",
"necessary",
"to",
"destruct",
"it",
"as",
"it",
"has",
"already",
"been",
"consumed",
"."
] | 971701a4e18aeffceda16f2538f3a846713e65ff | https://github.com/iduartgomez/rustypy/blob/971701a4e18aeffceda16f2538f3a846713e65ff/src/rustypy/rswrapper/pytypes.py#L39-L46 | train | Consumes the wrapper and returns a Python string. Afterwards is not necessary to destruct it as it has already been consumed. |
erijo/tellive-py | tellive/tellstick.py | TellstickLiveClient.servers | def servers(self, server='api.telldus.com', port=http.HTTPS_PORT):
"""Fetch list of servers that can be connected to.
:return: list of (address, port) tuples
"""
logging.debug("Fetching server list from %s:%d", server, port)
conn = http.HTTPSConnection(server, port, context=sel... | python | def servers(self, server='api.telldus.com', port=http.HTTPS_PORT):
"""Fetch list of servers that can be connected to.
:return: list of (address, port) tuples
"""
logging.debug("Fetching server list from %s:%d", server, port)
conn = http.HTTPSConnection(server, port, context=sel... | [
"def",
"servers",
"(",
"self",
",",
"server",
"=",
"'api.telldus.com'",
",",
"port",
"=",
"http",
".",
"HTTPS_PORT",
")",
":",
"logging",
".",
"debug",
"(",
"\"Fetching server list from %s:%d\"",
",",
"server",
",",
"port",
")",
"conn",
"=",
"http",
".",
"... | Fetch list of servers that can be connected to.
:return: list of (address, port) tuples | [
"Fetch",
"list",
"of",
"servers",
"that",
"can",
"be",
"connected",
"to",
"."
] | a84ebb1eb29ee4c69a085e55e523ac5fff0087fc | https://github.com/erijo/tellive-py/blob/a84ebb1eb29ee4c69a085e55e523ac5fff0087fc/tellive/tellstick.py#L56-L83 | train | Fetch list of servers that can be connected to. |
hbldh/dlxsudoku | dlxsudoku/dancing_links.py | DancingLinksSolver.solve | def solve(self):
"""Runs the Dancing Links/Algorithm X solver on the Sudoku.
This code has been adapted from http://www.cs.mcgill.ca/~aassaf9/python/algorithm_x.html
:return: List of lists with the same size as the input Sudoku, representing solutions.
:rtype: list
"""
... | python | def solve(self):
"""Runs the Dancing Links/Algorithm X solver on the Sudoku.
This code has been adapted from http://www.cs.mcgill.ca/~aassaf9/python/algorithm_x.html
:return: List of lists with the same size as the input Sudoku, representing solutions.
:rtype: list
"""
... | [
"def",
"solve",
"(",
"self",
")",
":",
"R",
",",
"C",
"=",
"int",
"(",
"math",
".",
"sqrt",
"(",
"len",
"(",
"self",
".",
"sudoku",
")",
")",
")",
",",
"int",
"(",
"math",
".",
"sqrt",
"(",
"len",
"(",
"self",
".",
"sudoku",
"[",
"0",
"]",
... | Runs the Dancing Links/Algorithm X solver on the Sudoku.
This code has been adapted from http://www.cs.mcgill.ca/~aassaf9/python/algorithm_x.html
:return: List of lists with the same size as the input Sudoku, representing solutions.
:rtype: list | [
"Runs",
"the",
"Dancing",
"Links",
"/",
"Algorithm",
"X",
"solver",
"on",
"the",
"Sudoku",
"."
] | 8d774e0883eb615533d04f07e58a95db716226e0 | https://github.com/hbldh/dlxsudoku/blob/8d774e0883eb615533d04f07e58a95db716226e0/dlxsudoku/dancing_links.py#L40-L78 | train | Runs the Dancing Links and Algorithm X solver on the Sudoku. |
ChrisBeaumont/smother | smother/git.py | execute | def execute(cmd):
"""Run a shell command and return stdout"""
proc = Popen(cmd, stdout=PIPE)
stdout, _ = proc.communicate()
if proc.returncode != 0:
raise CalledProcessError(proc.returncode, " ".join(cmd))
return stdout.decode('utf8') | python | def execute(cmd):
"""Run a shell command and return stdout"""
proc = Popen(cmd, stdout=PIPE)
stdout, _ = proc.communicate()
if proc.returncode != 0:
raise CalledProcessError(proc.returncode, " ".join(cmd))
return stdout.decode('utf8') | [
"def",
"execute",
"(",
"cmd",
")",
":",
"proc",
"=",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"PIPE",
")",
"stdout",
",",
"_",
"=",
"proc",
".",
"communicate",
"(",
")",
"if",
"proc",
".",
"returncode",
"!=",
"0",
":",
"raise",
"CalledProcessError",
... | Run a shell command and return stdout | [
"Run",
"a",
"shell",
"command",
"and",
"return",
"stdout"
] | 65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb | https://github.com/ChrisBeaumont/smother/blob/65d1ea6ae0060d213b0dcbb983c5aa8e7fee07bb/smother/git.py#L11-L18 | train | Run a shell command and return stdout |
SHDShim/pytheos | pytheos/etc.py | isuncertainties | def isuncertainties(arg_list):
"""
check if the input list contains any elements with uncertainties class
:param arg_list: list of arguments
:return: True/False
"""
for arg in arg_list:
if isinstance(arg, (list, tuple)) and isinstance(arg[0], uct.UFloat):
return True
... | python | def isuncertainties(arg_list):
"""
check if the input list contains any elements with uncertainties class
:param arg_list: list of arguments
:return: True/False
"""
for arg in arg_list:
if isinstance(arg, (list, tuple)) and isinstance(arg[0], uct.UFloat):
return True
... | [
"def",
"isuncertainties",
"(",
"arg_list",
")",
":",
"for",
"arg",
"in",
"arg_list",
":",
"if",
"isinstance",
"(",
"arg",
",",
"(",
"list",
",",
"tuple",
")",
")",
"and",
"isinstance",
"(",
"arg",
"[",
"0",
"]",
",",
"uct",
".",
"UFloat",
")",
":",... | check if the input list contains any elements with uncertainties class
:param arg_list: list of arguments
:return: True/False | [
"check",
"if",
"the",
"input",
"list",
"contains",
"any",
"elements",
"with",
"uncertainties",
"class"
] | be079624405e92fbec60c5ead253eb5917e55237 | https://github.com/SHDShim/pytheos/blob/be079624405e92fbec60c5ead253eb5917e55237/pytheos/etc.py#L5-L21 | train | check if the input list contains any elements with uncertainties class
|
potatolondon/gae-pytz | makezoneinfo.py | filter_tzfiles | def filter_tzfiles(name_list):
"""Returns a list of tuples for names that are tz data files."""
for src_name in name_list:
# pytz-2012j/pytz/zoneinfo/Indian/Christmas
parts = src_name.split('/')
if len(parts) > 3 and parts[2] == 'zoneinfo':
dst_name = '/'.join(parts[2:])
... | python | def filter_tzfiles(name_list):
"""Returns a list of tuples for names that are tz data files."""
for src_name in name_list:
# pytz-2012j/pytz/zoneinfo/Indian/Christmas
parts = src_name.split('/')
if len(parts) > 3 and parts[2] == 'zoneinfo':
dst_name = '/'.join(parts[2:])
... | [
"def",
"filter_tzfiles",
"(",
"name_list",
")",
":",
"for",
"src_name",
"in",
"name_list",
":",
"# pytz-2012j/pytz/zoneinfo/Indian/Christmas",
"parts",
"=",
"src_name",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
"(",
"parts",
")",
">",
"3",
"and",
"parts",
... | Returns a list of tuples for names that are tz data files. | [
"Returns",
"a",
"list",
"of",
"tuples",
"for",
"names",
"that",
"are",
"tz",
"data",
"files",
"."
] | 24741951a7af3e79cd8727ae3f79265decc93fef | https://github.com/potatolondon/gae-pytz/blob/24741951a7af3e79cd8727ae3f79265decc93fef/makezoneinfo.py#L15-L22 | train | Returns a list of tuples for names that are tz data files. |
potatolondon/gae-pytz | makezoneinfo.py | extract_zip | def extract_zip(fileobj):
"""Yields 3-tuples of (name, modified, bytes)."""
archive = zipfile.ZipFile(fileobj, mode='r')
filenames = archive.namelist()
for src_name, dst_name in filter_tzfiles(filenames):
modified = archive.getinfo(src_name).date_time
bytes = archive.read(src_name)
... | python | def extract_zip(fileobj):
"""Yields 3-tuples of (name, modified, bytes)."""
archive = zipfile.ZipFile(fileobj, mode='r')
filenames = archive.namelist()
for src_name, dst_name in filter_tzfiles(filenames):
modified = archive.getinfo(src_name).date_time
bytes = archive.read(src_name)
... | [
"def",
"extract_zip",
"(",
"fileobj",
")",
":",
"archive",
"=",
"zipfile",
".",
"ZipFile",
"(",
"fileobj",
",",
"mode",
"=",
"'r'",
")",
"filenames",
"=",
"archive",
".",
"namelist",
"(",
")",
"for",
"src_name",
",",
"dst_name",
"in",
"filter_tzfiles",
"... | Yields 3-tuples of (name, modified, bytes). | [
"Yields",
"3",
"-",
"tuples",
"of",
"(",
"name",
"modified",
"bytes",
")",
"."
] | 24741951a7af3e79cd8727ae3f79265decc93fef | https://github.com/potatolondon/gae-pytz/blob/24741951a7af3e79cd8727ae3f79265decc93fef/makezoneinfo.py#L25-L34 | train | Yields 3 - tuples of name modified bytes. |
potatolondon/gae-pytz | makezoneinfo.py | extract_tar | def extract_tar(fileobj):
"""Yields 3-tuples of (name, modified, bytes)."""
import time
archive = tarfile.open(fileobj=fileobj)
filenames = [info.name for info in archive.getmembers() if info.isfile()]
for src_name, dst_name in filter_tzfiles(filenames):
mtime = archive.getmember(src_name)... | python | def extract_tar(fileobj):
"""Yields 3-tuples of (name, modified, bytes)."""
import time
archive = tarfile.open(fileobj=fileobj)
filenames = [info.name for info in archive.getmembers() if info.isfile()]
for src_name, dst_name in filter_tzfiles(filenames):
mtime = archive.getmember(src_name)... | [
"def",
"extract_tar",
"(",
"fileobj",
")",
":",
"import",
"time",
"archive",
"=",
"tarfile",
".",
"open",
"(",
"fileobj",
"=",
"fileobj",
")",
"filenames",
"=",
"[",
"info",
".",
"name",
"for",
"info",
"in",
"archive",
".",
"getmembers",
"(",
")",
"if"... | Yields 3-tuples of (name, modified, bytes). | [
"Yields",
"3",
"-",
"tuples",
"of",
"(",
"name",
"modified",
"bytes",
")",
"."
] | 24741951a7af3e79cd8727ae3f79265decc93fef | https://github.com/potatolondon/gae-pytz/blob/24741951a7af3e79cd8727ae3f79265decc93fef/makezoneinfo.py#L37-L49 | train | Yields 3 - tuples of name modified bytes |
totalgood/twip | twip/scripts/skeleton.py | parse_args | def parse_args(args):
"""
Parse command line parameters
:param args: command line parameters as list of strings
:return: command line parameters as :obj:`argparse.Namespace`
"""
parser = argparse.ArgumentParser(
description="Just a Hello World demonstration")
parser.add_argument(
... | python | def parse_args(args):
"""
Parse command line parameters
:param args: command line parameters as list of strings
:return: command line parameters as :obj:`argparse.Namespace`
"""
parser = argparse.ArgumentParser(
description="Just a Hello World demonstration")
parser.add_argument(
... | [
"def",
"parse_args",
"(",
"args",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Just a Hello World demonstration\"",
")",
"parser",
".",
"add_argument",
"(",
"'-v'",
",",
"'--version'",
",",
"action",
"=",
"'version'",
"... | Parse command line parameters
:param args: command line parameters as list of strings
:return: command line parameters as :obj:`argparse.Namespace` | [
"Parse",
"command",
"line",
"parameters"
] | 5c0411d2acfbe5b421841072814c9152591c03f7 | https://github.com/totalgood/twip/blob/5c0411d2acfbe5b421841072814c9152591c03f7/twip/scripts/skeleton.py#L33-L47 | train | Parse command line parameters as list of strings |
klen/muffin-admin | muffin_admin/plugin.py | Plugin.setup | def setup(self, app):
""" Initialize the application. """
super().setup(app)
self.handlers = OrderedDict()
# Connect admin templates
app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates'))
@app.ps.jinja2.filter
def admtest(value, a, b=None)... | python | def setup(self, app):
""" Initialize the application. """
super().setup(app)
self.handlers = OrderedDict()
# Connect admin templates
app.ps.jinja2.cfg.template_folders.append(op.join(PLUGIN_ROOT, 'templates'))
@app.ps.jinja2.filter
def admtest(value, a, b=None)... | [
"def",
"setup",
"(",
"self",
",",
"app",
")",
":",
"super",
"(",
")",
".",
"setup",
"(",
"app",
")",
"self",
".",
"handlers",
"=",
"OrderedDict",
"(",
")",
"# Connect admin templates",
"app",
".",
"ps",
".",
"jinja2",
".",
"cfg",
".",
"template_folders... | Initialize the application. | [
"Initialize",
"the",
"application",
"."
] | 404dc8e5107e943b7c42fa21c679c34ddb4de1d5 | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/plugin.py#L44-L99 | train | Initialize the application. |
klen/muffin-admin | muffin_admin/plugin.py | Plugin.register | def register(self, *handlers, **params):
""" Ensure that handler is not registered. """
for handler in handlers:
if issubclass(handler, PWModel):
handler = type(
handler._meta.db_table.title() + 'Admin',
(PWAdminHandler,), dict(model=h... | python | def register(self, *handlers, **params):
""" Ensure that handler is not registered. """
for handler in handlers:
if issubclass(handler, PWModel):
handler = type(
handler._meta.db_table.title() + 'Admin',
(PWAdminHandler,), dict(model=h... | [
"def",
"register",
"(",
"self",
",",
"*",
"handlers",
",",
"*",
"*",
"params",
")",
":",
"for",
"handler",
"in",
"handlers",
":",
"if",
"issubclass",
"(",
"handler",
",",
"PWModel",
")",
":",
"handler",
"=",
"type",
"(",
"handler",
".",
"_meta",
".",... | Ensure that handler is not registered. | [
"Ensure",
"that",
"handler",
"is",
"not",
"registered",
"."
] | 404dc8e5107e943b7c42fa21c679c34ddb4de1d5 | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/plugin.py#L101-L113 | train | Register a new handler. |
klen/muffin-admin | muffin_admin/plugin.py | Plugin.authorization | def authorization(self, func):
""" Define a authorization process. """
if self.app is None:
raise PluginException('The plugin must be installed to application.')
self.authorize = muffin.to_coroutine(func)
return func | python | def authorization(self, func):
""" Define a authorization process. """
if self.app is None:
raise PluginException('The plugin must be installed to application.')
self.authorize = muffin.to_coroutine(func)
return func | [
"def",
"authorization",
"(",
"self",
",",
"func",
")",
":",
"if",
"self",
".",
"app",
"is",
"None",
":",
"raise",
"PluginException",
"(",
"'The plugin must be installed to application.'",
")",
"self",
".",
"authorize",
"=",
"muffin",
".",
"to_coroutine",
"(",
... | Define a authorization process. | [
"Define",
"a",
"authorization",
"process",
"."
] | 404dc8e5107e943b7c42fa21c679c34ddb4de1d5 | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/plugin.py#L115-L121 | train | Define a authorization process. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/filesystem_walk.py | scandir_walk | def scandir_walk(top, skip_dirs=(), on_skip=None):
"""
Just walk the filesystem tree top-down with os.scandir() and don't follow symlinks.
:param top: path to scan
:param skip_dirs: List of dir names to skip
e.g.: "__pycache__", "temp", "tmp"
:param on_skip: function that will be called if '... | python | def scandir_walk(top, skip_dirs=(), on_skip=None):
"""
Just walk the filesystem tree top-down with os.scandir() and don't follow symlinks.
:param top: path to scan
:param skip_dirs: List of dir names to skip
e.g.: "__pycache__", "temp", "tmp"
:param on_skip: function that will be called if '... | [
"def",
"scandir_walk",
"(",
"top",
",",
"skip_dirs",
"=",
"(",
")",
",",
"on_skip",
"=",
"None",
")",
":",
"# We may not have read permission for top, in which case we can't",
"# get a list of the files the directory contains. os.walk",
"# always suppressed the exception then, rat... | Just walk the filesystem tree top-down with os.scandir() and don't follow symlinks.
:param top: path to scan
:param skip_dirs: List of dir names to skip
e.g.: "__pycache__", "temp", "tmp"
:param on_skip: function that will be called if 'skip_dirs' match.
e.g.:
def on_skip(entry, patt... | [
"Just",
"walk",
"the",
"filesystem",
"tree",
"top",
"-",
"down",
"with",
"os",
".",
"scandir",
"()",
"and",
"don",
"t",
"follow",
"symlinks",
".",
":",
"param",
"top",
":",
"path",
"to",
"scan",
":",
"param",
"skip_dirs",
":",
"List",
"of",
"dir",
"n... | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/filesystem_walk.py#L9-L39 | train | Recursively walk the filesystem tree top - down with os. scandir and don t follow symlinks. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/filesystem_walk.py | scandir_limited | def scandir_limited(top, limit, deep=0):
"""
yields only directories with the given deep limit
:param top: source path
:param limit: how deep should be scanned?
:param deep: internal deep number
:return: yields os.DirEntry() instances
"""
deep += 1
try:
scandir_it = Path2(to... | python | def scandir_limited(top, limit, deep=0):
"""
yields only directories with the given deep limit
:param top: source path
:param limit: how deep should be scanned?
:param deep: internal deep number
:return: yields os.DirEntry() instances
"""
deep += 1
try:
scandir_it = Path2(to... | [
"def",
"scandir_limited",
"(",
"top",
",",
"limit",
",",
"deep",
"=",
"0",
")",
":",
"deep",
"+=",
"1",
"try",
":",
"scandir_it",
"=",
"Path2",
"(",
"top",
")",
".",
"scandir",
"(",
")",
"except",
"PermissionError",
"as",
"err",
":",
"log",
".",
"e... | yields only directories with the given deep limit
:param top: source path
:param limit: how deep should be scanned?
:param deep: internal deep number
:return: yields os.DirEntry() instances | [
"yields",
"only",
"directories",
"with",
"the",
"given",
"deep",
"limit"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/filesystem_walk.py#L42-L63 | train | yields all directories with the given deep limit |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/filesystem_walk.py | iter_filtered_dir_entry | def iter_filtered_dir_entry(dir_entries, match_patterns, on_skip):
"""
Filter a list of DirEntryPath instances with the given pattern
:param dir_entries: list of DirEntryPath instances
:param match_patterns: used with Path.match()
e.g.: "__pycache__/*", "*.tmp", "*.cache"
:param on_skip: fu... | python | def iter_filtered_dir_entry(dir_entries, match_patterns, on_skip):
"""
Filter a list of DirEntryPath instances with the given pattern
:param dir_entries: list of DirEntryPath instances
:param match_patterns: used with Path.match()
e.g.: "__pycache__/*", "*.tmp", "*.cache"
:param on_skip: fu... | [
"def",
"iter_filtered_dir_entry",
"(",
"dir_entries",
",",
"match_patterns",
",",
"on_skip",
")",
":",
"def",
"match",
"(",
"dir_entry_path",
",",
"match_patterns",
",",
"on_skip",
")",
":",
"for",
"match_pattern",
"in",
"match_patterns",
":",
"if",
"dir_entry_pat... | Filter a list of DirEntryPath instances with the given pattern
:param dir_entries: list of DirEntryPath instances
:param match_patterns: used with Path.match()
e.g.: "__pycache__/*", "*.tmp", "*.cache"
:param on_skip: function that will be called if 'match_patterns' hits.
e.g.:
def ... | [
"Filter",
"a",
"list",
"of",
"DirEntryPath",
"instances",
"with",
"the",
"given",
"pattern"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/filesystem_walk.py#L85-L118 | train | Iterate a list of DirEntryPath instances with the given pattern. |
jedie/PyHardLinkBackup | PyHardLinkBackup/phlb/filesystem_walk.py | PathLibFilter.iter | def iter(self, dir_entries):
"""
:param dir_entries: list of os.DirEntry() instances
"""
filter = self.filter
for entry in dir_entries:
path = filter(Path2(entry.path))
if path != False:
yield path | python | def iter(self, dir_entries):
"""
:param dir_entries: list of os.DirEntry() instances
"""
filter = self.filter
for entry in dir_entries:
path = filter(Path2(entry.path))
if path != False:
yield path | [
"def",
"iter",
"(",
"self",
",",
"dir_entries",
")",
":",
"filter",
"=",
"self",
".",
"filter",
"for",
"entry",
"in",
"dir_entries",
":",
"path",
"=",
"filter",
"(",
"Path2",
"(",
"entry",
".",
"path",
")",
")",
"if",
"path",
"!=",
"False",
":",
"y... | :param dir_entries: list of os.DirEntry() instances | [
":",
"param",
"dir_entries",
":",
"list",
"of",
"os",
".",
"DirEntry",
"()",
"instances"
] | be28666834d2d9e3d8aac1b661cb2d5bd4056c29 | https://github.com/jedie/PyHardLinkBackup/blob/be28666834d2d9e3d8aac1b661cb2d5bd4056c29/PyHardLinkBackup/phlb/filesystem_walk.py#L74-L82 | train | returns an iterator over the directory entries that are not empty |
Capitains/MyCapytain | MyCapytain/common/utils/_http.py | parse_pagination | def parse_pagination(headers):
""" Parses headers to create a pagination objects
:param headers: HTTP Headers
:type headers: dict
:return: Navigation object for pagination
:rtype: _Navigation
"""
links = {
link.rel: parse_qs(link.href).get("page", None)
for link in link_head... | python | def parse_pagination(headers):
""" Parses headers to create a pagination objects
:param headers: HTTP Headers
:type headers: dict
:return: Navigation object for pagination
:rtype: _Navigation
"""
links = {
link.rel: parse_qs(link.href).get("page", None)
for link in link_head... | [
"def",
"parse_pagination",
"(",
"headers",
")",
":",
"links",
"=",
"{",
"link",
".",
"rel",
":",
"parse_qs",
"(",
"link",
".",
"href",
")",
".",
"get",
"(",
"\"page\"",
",",
"None",
")",
"for",
"link",
"in",
"link_header",
".",
"parse",
"(",
"headers... | Parses headers to create a pagination objects
:param headers: HTTP Headers
:type headers: dict
:return: Navigation object for pagination
:rtype: _Navigation | [
"Parses",
"headers",
"to",
"create",
"a",
"pagination",
"objects"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/_http.py#L10-L28 | train | Parses the HTTP Headers to create a pagination object for the current page and last pages. |
Capitains/MyCapytain | MyCapytain/common/utils/_http.py | parse_uri | def parse_uri(uri, endpoint_uri):
""" Parse a URI into a Route namedtuple
:param uri: URI or relative URI
:type uri: str
:param endpoint_uri: URI of the endpoint
:type endpoint_uri: str
:return: Parsed route
:rtype: _Route
"""
temp_parse = urlparse(uri)
return _Route(
ur... | python | def parse_uri(uri, endpoint_uri):
""" Parse a URI into a Route namedtuple
:param uri: URI or relative URI
:type uri: str
:param endpoint_uri: URI of the endpoint
:type endpoint_uri: str
:return: Parsed route
:rtype: _Route
"""
temp_parse = urlparse(uri)
return _Route(
ur... | [
"def",
"parse_uri",
"(",
"uri",
",",
"endpoint_uri",
")",
":",
"temp_parse",
"=",
"urlparse",
"(",
"uri",
")",
"return",
"_Route",
"(",
"urljoin",
"(",
"endpoint_uri",
",",
"temp_parse",
".",
"path",
")",
",",
"parse_qs",
"(",
"temp_parse",
".",
"query",
... | Parse a URI into a Route namedtuple
:param uri: URI or relative URI
:type uri: str
:param endpoint_uri: URI of the endpoint
:type endpoint_uri: str
:return: Parsed route
:rtype: _Route | [
"Parse",
"a",
"URI",
"into",
"a",
"Route",
"namedtuple"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/_http.py#L31-L45 | train | Parse a URI into a named tuple containing the path query and the url of the current resource. |
etingof/pysnmpcrypto | pysnmpcrypto/aes.py | _cryptodome_cipher | def _cryptodome_cipher(key, iv):
"""Build a Pycryptodome AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance
"""
return AES.new(key, AES.MODE_CFB, iv, segment_size=128) | python | def _cryptodome_cipher(key, iv):
"""Build a Pycryptodome AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance
"""
return AES.new(key, AES.MODE_CFB, iv, segment_size=128) | [
"def",
"_cryptodome_cipher",
"(",
"key",
",",
"iv",
")",
":",
"return",
"AES",
".",
"new",
"(",
"key",
",",
"AES",
".",
"MODE_CFB",
",",
"iv",
",",
"segment_size",
"=",
"128",
")"
] | Build a Pycryptodome AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance | [
"Build",
"a",
"Pycryptodome",
"AES",
"Cipher",
"object",
"."
] | 9b92959f5e2fce833fa220343ca12add3134a77c | https://github.com/etingof/pysnmpcrypto/blob/9b92959f5e2fce833fa220343ca12add3134a77c/pysnmpcrypto/aes.py#L17-L24 | train | Build a Pycryptodome AES Cipher object. |
etingof/pysnmpcrypto | pysnmpcrypto/aes.py | _cryptography_cipher | def _cryptography_cipher(key, iv):
"""Build a cryptography AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance
:rtype: cryptography.hazmat.primitives.ciphers.Cipher
"""
return Cipher(
algorithm=algorithms.AES(key),... | python | def _cryptography_cipher(key, iv):
"""Build a cryptography AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance
:rtype: cryptography.hazmat.primitives.ciphers.Cipher
"""
return Cipher(
algorithm=algorithms.AES(key),... | [
"def",
"_cryptography_cipher",
"(",
"key",
",",
"iv",
")",
":",
"return",
"Cipher",
"(",
"algorithm",
"=",
"algorithms",
".",
"AES",
"(",
"key",
")",
",",
"mode",
"=",
"modes",
".",
"CFB",
"(",
"iv",
")",
",",
"backend",
"=",
"default_backend",
"(",
... | Build a cryptography AES Cipher object.
:param bytes key: Encryption key
:param bytes iv: Initialization vector
:returns: AES Cipher instance
:rtype: cryptography.hazmat.primitives.ciphers.Cipher | [
"Build",
"a",
"cryptography",
"AES",
"Cipher",
"object",
"."
] | 9b92959f5e2fce833fa220343ca12add3134a77c | https://github.com/etingof/pysnmpcrypto/blob/9b92959f5e2fce833fa220343ca12add3134a77c/pysnmpcrypto/aes.py#L27-L39 | train | Build a cryptography AES Cipher object. |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | make_xml_node | def make_xml_node(graph, name, close=False, attributes=None, text="", complete=False, innerXML=""):
""" Create an XML Node
:param graph: Graph used to geneates prefixes
:param name: Name of the tag
:param close: Produce closing tag (close=False -> "<tag>", close=True -> "</tag>")
:param attributes:... | python | def make_xml_node(graph, name, close=False, attributes=None, text="", complete=False, innerXML=""):
""" Create an XML Node
:param graph: Graph used to geneates prefixes
:param name: Name of the tag
:param close: Produce closing tag (close=False -> "<tag>", close=True -> "</tag>")
:param attributes:... | [
"def",
"make_xml_node",
"(",
"graph",
",",
"name",
",",
"close",
"=",
"False",
",",
"attributes",
"=",
"None",
",",
"text",
"=",
"\"\"",
",",
"complete",
"=",
"False",
",",
"innerXML",
"=",
"\"\"",
")",
":",
"name",
"=",
"graph",
".",
"namespace_manage... | Create an XML Node
:param graph: Graph used to geneates prefixes
:param name: Name of the tag
:param close: Produce closing tag (close=False -> "<tag>", close=True -> "</tag>")
:param attributes: Dictionary of attributes
:param text: CapitainsCtsText to put inside the node
:param complete: Comp... | [
"Create",
"an",
"XML",
"Node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L27-L67 | train | Creates an XML node for the given node name. |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | xmlparser | def xmlparser(xml, objectify=True):
""" Parse xml
:param xml: XML element
:type xml: Union[text_type, lxml.etree._Element]
:rtype: lxml.etree._Element
:returns: An element object
:raises: TypeError if element is not in accepted type
"""
doclose = None
if isinstance(xml, (etree._Ele... | python | def xmlparser(xml, objectify=True):
""" Parse xml
:param xml: XML element
:type xml: Union[text_type, lxml.etree._Element]
:rtype: lxml.etree._Element
:returns: An element object
:raises: TypeError if element is not in accepted type
"""
doclose = None
if isinstance(xml, (etree._Ele... | [
"def",
"xmlparser",
"(",
"xml",
",",
"objectify",
"=",
"True",
")",
":",
"doclose",
"=",
"None",
"if",
"isinstance",
"(",
"xml",
",",
"(",
"etree",
".",
"_Element",
",",
"ObjectifiedElement",
",",
"etree",
".",
"_ElementTree",
")",
")",
":",
"return",
... | Parse xml
:param xml: XML element
:type xml: Union[text_type, lxml.etree._Element]
:rtype: lxml.etree._Element
:returns: An element object
:raises: TypeError if element is not in accepted type | [
"Parse",
"xml"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L82-L107 | train | Parse an XML element and return the root element. |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | performXpath | def performXpath(parent, xpath):
""" Perform an XPath on an element and indicate if we need to loop over it to find something
:param parent: XML Node on which to perform XPath
:param xpath: XPath to run
:return: (Result, Need to loop Indicator)
"""
loop = False
if xpath.startswith(".//"):
... | python | def performXpath(parent, xpath):
""" Perform an XPath on an element and indicate if we need to loop over it to find something
:param parent: XML Node on which to perform XPath
:param xpath: XPath to run
:return: (Result, Need to loop Indicator)
"""
loop = False
if xpath.startswith(".//"):
... | [
"def",
"performXpath",
"(",
"parent",
",",
"xpath",
")",
":",
"loop",
"=",
"False",
"if",
"xpath",
".",
"startswith",
"(",
"\".//\"",
")",
":",
"result",
"=",
"parent",
".",
"xpath",
"(",
"xpath",
".",
"replace",
"(",
"\".//\"",
",",
"\"./\"",
",",
"... | Perform an XPath on an element and indicate if we need to loop over it to find something
:param parent: XML Node on which to perform XPath
:param xpath: XPath to run
:return: (Result, Need to loop Indicator) | [
"Perform",
"an",
"XPath",
"on",
"an",
"element",
"and",
"indicate",
"if",
"we",
"need",
"to",
"loop",
"over",
"it",
"to",
"find",
"something"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L129-L153 | train | Perform an XPath on an element and indicate if we need to loop over it. |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | copyNode | def copyNode(node, children=False, parent=False):
""" Copy an XML Node
:param node: Etree Node
:param children: Copy children nodes is set to True
:param parent: Append copied node to parent if given
:return: New Element
"""
if parent is not False:
element = SubElement(
... | python | def copyNode(node, children=False, parent=False):
""" Copy an XML Node
:param node: Etree Node
:param children: Copy children nodes is set to True
:param parent: Append copied node to parent if given
:return: New Element
"""
if parent is not False:
element = SubElement(
... | [
"def",
"copyNode",
"(",
"node",
",",
"children",
"=",
"False",
",",
"parent",
"=",
"False",
")",
":",
"if",
"parent",
"is",
"not",
"False",
":",
"element",
"=",
"SubElement",
"(",
"parent",
",",
"node",
".",
"tag",
",",
"attrib",
"=",
"node",
".",
... | Copy an XML Node
:param node: Etree Node
:param children: Copy children nodes is set to True
:param parent: Append copied node to parent if given
:return: New Element | [
"Copy",
"an",
"XML",
"Node"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L156-L182 | train | Copy an XML node to a new Element |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | normalizeXpath | def normalizeXpath(xpath):
""" Normalize XPATH split around slashes
:param xpath: List of xpath elements
:type xpath: [str]
:return: List of refined xpath
:rtype: [str]
"""
new_xpath = []
for x in range(0, len(xpath)):
if x > 0 and len(xpath[x-1]) == 0:
new_xpath.app... | python | def normalizeXpath(xpath):
""" Normalize XPATH split around slashes
:param xpath: List of xpath elements
:type xpath: [str]
:return: List of refined xpath
:rtype: [str]
"""
new_xpath = []
for x in range(0, len(xpath)):
if x > 0 and len(xpath[x-1]) == 0:
new_xpath.app... | [
"def",
"normalizeXpath",
"(",
"xpath",
")",
":",
"new_xpath",
"=",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"xpath",
")",
")",
":",
"if",
"x",
">",
"0",
"and",
"len",
"(",
"xpath",
"[",
"x",
"-",
"1",
"]",
")",
"==",
... | Normalize XPATH split around slashes
:param xpath: List of xpath elements
:type xpath: [str]
:return: List of refined xpath
:rtype: [str] | [
"Normalize",
"XPATH",
"split",
"around",
"slashes"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L185-L199 | train | Normalize XPATH split around slashes and return a new list of xpath elements |
Capitains/MyCapytain | MyCapytain/common/utils/xml.py | passageLoop | def passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False):
""" Loop over passages to construct and increment new tree given a parent and XPaths
:param parent: Parent on which to perform xpath
:param new_tree: Parent on which to add nodes
:param xpath1: L... | python | def passageLoop(parent, new_tree, xpath1, xpath2=None, preceding_siblings=False, following_siblings=False):
""" Loop over passages to construct and increment new tree given a parent and XPaths
:param parent: Parent on which to perform xpath
:param new_tree: Parent on which to add nodes
:param xpath1: L... | [
"def",
"passageLoop",
"(",
"parent",
",",
"new_tree",
",",
"xpath1",
",",
"xpath2",
"=",
"None",
",",
"preceding_siblings",
"=",
"False",
",",
"following_siblings",
"=",
"False",
")",
":",
"current_1",
",",
"queue_1",
"=",
"__formatXpath__",
"(",
"xpath1",
"... | Loop over passages to construct and increment new tree given a parent and XPaths
:param parent: Parent on which to perform xpath
:param new_tree: Parent on which to add nodes
:param xpath1: List of xpath elements
:type xpath1: [str]
:param xpath2: List of xpath elements
:type xpath2: [str]
... | [
"Loop",
"over",
"passages",
"to",
"construct",
"and",
"increment",
"new",
"tree",
"given",
"a",
"parent",
"and",
"XPaths"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/common/utils/xml.py#L202-L304 | train | Loop over passages to construct and increment a new tree given a parent and an xpath. |
Capitains/MyCapytain | MyCapytain/resources/prototypes/metadata.py | Collection.get_label | def get_label(self, lang=None):
""" Return label for given lang or any default
:param lang: Language to request
:return: Label value
:rtype: Literal
"""
x = None
if lang is None:
for obj in self.graph.objects(self.asNode(), RDFS.label):
... | python | def get_label(self, lang=None):
""" Return label for given lang or any default
:param lang: Language to request
:return: Label value
:rtype: Literal
"""
x = None
if lang is None:
for obj in self.graph.objects(self.asNode(), RDFS.label):
... | [
"def",
"get_label",
"(",
"self",
",",
"lang",
"=",
"None",
")",
":",
"x",
"=",
"None",
"if",
"lang",
"is",
"None",
":",
"for",
"obj",
"in",
"self",
".",
"graph",
".",
"objects",
"(",
"self",
".",
"asNode",
"(",
")",
",",
"RDFS",
".",
"label",
"... | Return label for given lang or any default
:param lang: Language to request
:return: Label value
:rtype: Literal | [
"Return",
"label",
"for",
"given",
"lang",
"or",
"any",
"default"
] | b11bbf6b6ae141fc02be70471e3fbf6907be6593 | https://github.com/Capitains/MyCapytain/blob/b11bbf6b6ae141fc02be70471e3fbf6907be6593/MyCapytain/resources/prototypes/metadata.py#L125-L140 | train | Return the label for given lang or any default |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.