repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_huisnummer_adapter | def item_huisnummer_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Huisnummer` to json.
"""
return {
'id': obj.id,
'huisnummer': obj.huisnummer,
'postadres': obj.postadres,
'status': {
'id': obj.status.id,
... | python | def item_huisnummer_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Huisnummer` to json.
"""
return {
'id': obj.id,
'huisnummer': obj.huisnummer,
'postadres': obj.postadres,
'status': {
'id': obj.status.id,
... | [
"def",
"item_huisnummer_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'huisnummer'",
":",
"obj",
".",
"huisnummer",
",",
"'postadres'",
":",
"obj",
".",
"postadres",
",",
"'status'",
":",
"{",
"'id'",... | Adapter for rendering an object of
:class:`crabpy.gateway.crab.Huisnummer` to json. | [
"Adapter",
"for",
"rendering",
"an",
"object",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"crab",
".",
"Huisnummer",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L304-L333 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_perceel_crab_adapter | def item_perceel_crab_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Perceel` to json.
"""
return {
'id': obj.id,
'centroid': obj.centroid,
'postadressen': obj.postadressen,
'metadata': {
'begin_tijd': obj.metadat... | python | def item_perceel_crab_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Perceel` to json.
"""
return {
'id': obj.id,
'centroid': obj.centroid,
'postadressen': obj.postadressen,
'metadata': {
'begin_tijd': obj.metadat... | [
"def",
"item_perceel_crab_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'centroid'",
":",
"obj",
".",
"centroid",
",",
"'postadressen'",
":",
"obj",
".",
"postadressen",
",",
"'metadata'",
":",
"{",
"... | Adapter for rendering an object of
:class:`crabpy.gateway.crab.Perceel` to json. | [
"Adapter",
"for",
"rendering",
"an",
"object",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"crab",
".",
"Perceel",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L336-L359 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_gebouw_adapter | def item_gebouw_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Gebouw` to json.
"""
return {
'id': obj.id,
'aard': {
'id': obj.aard.id,
'naam': obj.aard.naam,
'definitie': obj.aard.definitie
},
... | python | def item_gebouw_adapter(obj, request):
"""
Adapter for rendering an object of
:class:`crabpy.gateway.crab.Gebouw` to json.
"""
return {
'id': obj.id,
'aard': {
'id': obj.aard.id,
'naam': obj.aard.naam,
'definitie': obj.aard.definitie
},
... | [
"def",
"item_gebouw_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'aard'",
":",
"{",
"'id'",
":",
"obj",
".",
"aard",
".",
"id",
",",
"'naam'",
":",
"obj",
".",
"aard",
".",
"naam",
",",
"'def... | Adapter for rendering an object of
:class:`crabpy.gateway.crab.Gebouw` to json. | [
"Adapter",
"for",
"rendering",
"an",
"object",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"crab",
".",
"Gebouw",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L362-L399 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_wegobject_adapter | def item_wegobject_adapter(obj, request):
"""
Adapter for rendering a list of
:class:`crabpy.gateway.Wegobject` to json.
"""
return {
'id': obj.id,
'aard': {
'id': obj.aard.id,
'naam': obj.aard.naam,
'definitie': obj.aard.definitie
},
... | python | def item_wegobject_adapter(obj, request):
"""
Adapter for rendering a list of
:class:`crabpy.gateway.Wegobject` to json.
"""
return {
'id': obj.id,
'aard': {
'id': obj.aard.id,
'naam': obj.aard.naam,
'definitie': obj.aard.definitie
},
... | [
"def",
"item_wegobject_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'aard'",
":",
"{",
"'id'",
":",
"obj",
".",
"aard",
".",
"id",
",",
"'naam'",
":",
"obj",
".",
"aard",
".",
"naam",
",",
"'... | Adapter for rendering a list of
:class:`crabpy.gateway.Wegobject` to json. | [
"Adapter",
"for",
"rendering",
"a",
"list",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"Wegobject",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L402-L430 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_subadres_adapter | def item_subadres_adapter(obj, request):
"""
Adapter for rendering an item of
:class:`crabpy.gateway.Subadres` to json.
"""
return {
'id': obj.id,
'subadres': obj.subadres,
'postadres': obj.postadres,
'status': {
'id': obj.status.id,
'naam': ob... | python | def item_subadres_adapter(obj, request):
"""
Adapter for rendering an item of
:class:`crabpy.gateway.Subadres` to json.
"""
return {
'id': obj.id,
'subadres': obj.subadres,
'postadres': obj.postadres,
'status': {
'id': obj.status.id,
'naam': ob... | [
"def",
"item_subadres_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'subadres'",
":",
"obj",
".",
"subadres",
",",
"'postadres'",
":",
"obj",
".",
"postadres",
",",
"'status'",
":",
"{",
"'id'",
":"... | Adapter for rendering an item of
:class:`crabpy.gateway.Subadres` to json. | [
"Adapter",
"for",
"rendering",
"an",
"item",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"Subadres",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L433-L466 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_adrespositie_adapter | def item_adrespositie_adapter(obj, request):
"""
Adapter for rendering an item of
:class:`crabpy.gateway.Adrespositie` to json.
"""
return {
'id': obj.id,
'herkomst': {
'id': obj.herkomst.id,
'naam': obj.herkomst.naam,
'definitie': obj.herkomst.def... | python | def item_adrespositie_adapter(obj, request):
"""
Adapter for rendering an item of
:class:`crabpy.gateway.Adrespositie` to json.
"""
return {
'id': obj.id,
'herkomst': {
'id': obj.herkomst.id,
'naam': obj.herkomst.naam,
'definitie': obj.herkomst.def... | [
"def",
"item_adrespositie_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"id",
",",
"'herkomst'",
":",
"{",
"'id'",
":",
"obj",
".",
"herkomst",
".",
"id",
",",
"'naam'",
":",
"obj",
".",
"herkomst",
".",
"naa... | Adapter for rendering an item of
:class:`crabpy.gateway.Adrespositie` to json. | [
"Adapter",
"for",
"rendering",
"an",
"item",
"of",
":",
"class",
":",
"crabpy",
".",
"gateway",
".",
"Adrespositie",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L469-L501 |
OnroerendErfgoed/crabpy_pyramid | crabpy_pyramid/renderers/crab.py | item_land_adapter | def item_land_adapter(obj, request):
"""
Adapter for rendering an item of
:class: `pycountry.db.Data` to json.
"""
return {
'id': obj.alpha_2,
'alpha2': obj.alpha_2,
'alpha3': obj.alpha_3,
'naam': _(obj.name)
} | python | def item_land_adapter(obj, request):
"""
Adapter for rendering an item of
:class: `pycountry.db.Data` to json.
"""
return {
'id': obj.alpha_2,
'alpha2': obj.alpha_2,
'alpha3': obj.alpha_3,
'naam': _(obj.name)
} | [
"def",
"item_land_adapter",
"(",
"obj",
",",
"request",
")",
":",
"return",
"{",
"'id'",
":",
"obj",
".",
"alpha_2",
",",
"'alpha2'",
":",
"obj",
".",
"alpha_2",
",",
"'alpha3'",
":",
"obj",
".",
"alpha_3",
",",
"'naam'",
":",
"_",
"(",
"obj",
".",
... | Adapter for rendering an item of
:class: `pycountry.db.Data` to json. | [
"Adapter",
"for",
"rendering",
"an",
"item",
"of",
":",
"class",
":",
"pycountry",
".",
"db",
".",
"Data",
"to",
"json",
"."
] | train | https://github.com/OnroerendErfgoed/crabpy_pyramid/blob/b727ea55838d71575db96e987b536a0bac9f6a7a/crabpy_pyramid/renderers/crab.py#L504-L514 |
ND-CSE-30151/tock | tock/graphviz.py | run_dot | def run_dot(dot):
"""Converts a graph in DOT format into an IPython displayable object."""
global impl
if impl is None:
impl = guess_impl()
if impl == "dot":
return run_dot_dot(dot)
elif impl == "js":
return run_dot_js(dot)
else:
raise ValueError("unknown implemen... | python | def run_dot(dot):
"""Converts a graph in DOT format into an IPython displayable object."""
global impl
if impl is None:
impl = guess_impl()
if impl == "dot":
return run_dot_dot(dot)
elif impl == "js":
return run_dot_js(dot)
else:
raise ValueError("unknown implemen... | [
"def",
"run_dot",
"(",
"dot",
")",
":",
"global",
"impl",
"if",
"impl",
"is",
"None",
":",
"impl",
"=",
"guess_impl",
"(",
")",
"if",
"impl",
"==",
"\"dot\"",
":",
"return",
"run_dot_dot",
"(",
"dot",
")",
"elif",
"impl",
"==",
"\"js\"",
":",
"return... | Converts a graph in DOT format into an IPython displayable object. | [
"Converts",
"a",
"graph",
"in",
"DOT",
"format",
"into",
"an",
"IPython",
"displayable",
"object",
"."
] | train | https://github.com/ND-CSE-30151/tock/blob/b8d21901aaf0e6ac913c2afa855f5b5a882a16c6/tock/graphviz.py#L31-L41 |
mitsei/dlkit | dlkit/primordium/locale/types/coordinate.py | get_type_data | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
if name in CELESTIAL_COORDINATE_TYPES:
domain = 'Celestial Coordinate Systems'
coordinate_name = CELESTIAL_COORDINATE_TYPES[name]
... | python | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
if name in CELESTIAL_COORDINATE_TYPES:
domain = 'Celestial Coordinate Systems'
coordinate_name = CELESTIAL_COORDINATE_TYPES[name]
... | [
"def",
"get_type_data",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"if",
"name",
"in",
"CELESTIAL_COORDINATE_TYPES",
":",
"domain",
"=",
"'Celestial Coordinate Systems'",
"coordinate_name",
"=",
"CELESTIAL_COORDINATE_TYPES",
"[",
"name",
"... | Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type | [
"Return",
"dictionary",
"representation",
"of",
"type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/primordium/locale/types/coordinate.py#L79-L103 |
mitsei/dlkit | dlkit/services/osid.py | OsidSession._get_agent_key | def _get_agent_key(self, proxy=None):
"""Gets an agent key for session management.
Side effect of setting a new proxy if one is sent along,
and initializing the provider session map if agent key has
not been seen before
"""
if self._proxy is None:
self._prox... | python | def _get_agent_key(self, proxy=None):
"""Gets an agent key for session management.
Side effect of setting a new proxy if one is sent along,
and initializing the provider session map if agent key has
not been seen before
"""
if self._proxy is None:
self._prox... | [
"def",
"_get_agent_key",
"(",
"self",
",",
"proxy",
"=",
"None",
")",
":",
"if",
"self",
".",
"_proxy",
"is",
"None",
":",
"self",
".",
"_proxy",
"=",
"proxy",
"if",
"self",
".",
"_proxy",
"is",
"not",
"None",
"and",
"self",
".",
"_proxy",
".",
"ha... | Gets an agent key for session management.
Side effect of setting a new proxy if one is sent along,
and initializing the provider session map if agent key has
not been seen before | [
"Gets",
"an",
"agent",
"key",
"for",
"session",
"management",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/osid.py#L295-L311 |
mitsei/dlkit | dlkit/services/osid.py | OsidSession._get_provider_sessions | def _get_provider_sessions(self):
"""Gets list of all known provider sessions."""
agent_key = self._get_agent_key()
sessions = []
for session_name in self._provider_sessions[agent_key]:
sessions.append(self._provider_sessions[agent_key][session_name])
return sessions | python | def _get_provider_sessions(self):
"""Gets list of all known provider sessions."""
agent_key = self._get_agent_key()
sessions = []
for session_name in self._provider_sessions[agent_key]:
sessions.append(self._provider_sessions[agent_key][session_name])
return sessions | [
"def",
"_get_provider_sessions",
"(",
"self",
")",
":",
"agent_key",
"=",
"self",
".",
"_get_agent_key",
"(",
")",
"sessions",
"=",
"[",
"]",
"for",
"session_name",
"in",
"self",
".",
"_provider_sessions",
"[",
"agent_key",
"]",
":",
"sessions",
".",
"append... | Gets list of all known provider sessions. | [
"Gets",
"list",
"of",
"all",
"known",
"provider",
"sessions",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/services/osid.py#L313-L319 |
peopledoc/django-agnocomplete | demo/fields.py | ModelMultipleDomainField.extra_create_kwargs | def extra_create_kwargs(self):
"""
Inject the domain of the current user in the new model instances.
"""
user = self.get_agnocomplete_context()
if user:
_, domain = user.email.split('@')
return {
'domain': domain
}
retur... | python | def extra_create_kwargs(self):
"""
Inject the domain of the current user in the new model instances.
"""
user = self.get_agnocomplete_context()
if user:
_, domain = user.email.split('@')
return {
'domain': domain
}
retur... | [
"def",
"extra_create_kwargs",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"get_agnocomplete_context",
"(",
")",
"if",
"user",
":",
"_",
",",
"domain",
"=",
"user",
".",
"email",
".",
"split",
"(",
"'@'",
")",
"return",
"{",
"'domain'",
":",
"domai... | Inject the domain of the current user in the new model instances. | [
"Inject",
"the",
"domain",
"of",
"the",
"current",
"user",
"in",
"the",
"new",
"model",
"instances",
"."
] | train | https://github.com/peopledoc/django-agnocomplete/blob/9bf21db2f2036ba5059b843acd32902a09192053/demo/fields.py#L11-L21 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | get_pseudo_salt | def get_pseudo_salt(length, *args):
"""
generate a pseudo salt (used, if user is wrong)
"""
temp = "".join([arg for arg in args])
return hash_hexdigest(temp)[:length] | python | def get_pseudo_salt(length, *args):
"""
generate a pseudo salt (used, if user is wrong)
"""
temp = "".join([arg for arg in args])
return hash_hexdigest(temp)[:length] | [
"def",
"get_pseudo_salt",
"(",
"length",
",",
"*",
"args",
")",
":",
"temp",
"=",
"\"\"",
".",
"join",
"(",
"[",
"arg",
"for",
"arg",
"in",
"args",
"]",
")",
"return",
"hash_hexdigest",
"(",
"temp",
")",
"[",
":",
"length",
"]"
] | generate a pseudo salt (used, if user is wrong) | [
"generate",
"a",
"pseudo",
"salt",
"(",
"used",
"if",
"user",
"is",
"wrong",
")"
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L83-L88 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | hexlify_pbkdf2 | def hexlify_pbkdf2(password, salt, iterations, length, digest=hashlib.sha1):
"""
>>> hash = hexlify_pbkdf2("not secret", "a salt value", iterations=100, length=16)
>>> hash == '0b919231515dde16f76364666cf07107'
True
"""
# log.debug("hexlify_pbkdf2 with iterations=%i", iterations)
hash = cryp... | python | def hexlify_pbkdf2(password, salt, iterations, length, digest=hashlib.sha1):
"""
>>> hash = hexlify_pbkdf2("not secret", "a salt value", iterations=100, length=16)
>>> hash == '0b919231515dde16f76364666cf07107'
True
"""
# log.debug("hexlify_pbkdf2 with iterations=%i", iterations)
hash = cryp... | [
"def",
"hexlify_pbkdf2",
"(",
"password",
",",
"salt",
",",
"iterations",
",",
"length",
",",
"digest",
"=",
"hashlib",
".",
"sha1",
")",
":",
"# log.debug(\"hexlify_pbkdf2 with iterations=%i\", iterations)",
"hash",
"=",
"crypto",
".",
"pbkdf2",
"(",
"password",
... | >>> hash = hexlify_pbkdf2("not secret", "a salt value", iterations=100, length=16)
>>> hash == '0b919231515dde16f76364666cf07107'
True | [
">>>",
"hash",
"=",
"hexlify_pbkdf2",
"(",
"not",
"secret",
"a",
"salt",
"value",
"iterations",
"=",
"100",
"length",
"=",
"16",
")",
">>>",
"hash",
"==",
"0b919231515dde16f76364666cf07107",
"True"
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L91-L101 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | salt_hash_from_plaintext | def salt_hash_from_plaintext(password):
"""
Create a XOR encrypted PBKDF2 salted checksum from a plaintext password.
>>> seed_generator.DEBUG=True # Generate always the same seed for tests
>>> salt, data = salt_hash_from_plaintext("test")
>>> salt == 'DEBUG'
True
>>> data =='pbkdf2_sha1$5$... | python | def salt_hash_from_plaintext(password):
"""
Create a XOR encrypted PBKDF2 salted checksum from a plaintext password.
>>> seed_generator.DEBUG=True # Generate always the same seed for tests
>>> salt, data = salt_hash_from_plaintext("test")
>>> salt == 'DEBUG'
True
>>> data =='pbkdf2_sha1$5$... | [
"def",
"salt_hash_from_plaintext",
"(",
"password",
")",
":",
"init_pbkdf2_salt",
"=",
"seed_generator",
"(",
"app_settings",
".",
"PBKDF2_SALT_LENGTH",
")",
"pbkdf2_temp_hash",
"=",
"hexlify_pbkdf2",
"(",
"password",
",",
"salt",
"=",
"init_pbkdf2_salt",
",",
"iterat... | Create a XOR encrypted PBKDF2 salted checksum from a plaintext password.
>>> seed_generator.DEBUG=True # Generate always the same seed for tests
>>> salt, data = salt_hash_from_plaintext("test")
>>> salt == 'DEBUG'
True
>>> data =='pbkdf2_sha1$5$DEBUG$a2220ab7dea891f260edd481$50530c0e530f030b08070... | [
"Create",
"a",
"XOR",
"encrypted",
"PBKDF2",
"salted",
"checksum",
"from",
"a",
"plaintext",
"password",
"."
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L323-L349 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | _simulate_client | def _simulate_client(plaintext_password, init_pbkdf2_salt, cnonce, server_challenge):
"""
A implementation of the JavaScript client part.
Needful for finding bugs.
"""
# log.debug("_simulate_client(plaintext_password='%s', init_pbkdf2_salt='%s', cnonce='%s', server_challenge='%s')",
# plaint... | python | def _simulate_client(plaintext_password, init_pbkdf2_salt, cnonce, server_challenge):
"""
A implementation of the JavaScript client part.
Needful for finding bugs.
"""
# log.debug("_simulate_client(plaintext_password='%s', init_pbkdf2_salt='%s', cnonce='%s', server_challenge='%s')",
# plaint... | [
"def",
"_simulate_client",
"(",
"plaintext_password",
",",
"init_pbkdf2_salt",
",",
"cnonce",
",",
"server_challenge",
")",
":",
"# log.debug(\"_simulate_client(plaintext_password='%s', init_pbkdf2_salt='%s', cnonce='%s', server_challenge='%s')\",",
"# plaintext_password, init_pbkdf2_s... | A implementation of the JavaScript client part.
Needful for finding bugs. | [
"A",
"implementation",
"of",
"the",
"JavaScript",
"client",
"part",
".",
"Needful",
"for",
"finding",
"bugs",
"."
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L352-L377 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | check_secure_js_login | def check_secure_js_login(secure_password, encrypted_part, server_challenge):
"""
first_pbkdf2_part = xor_decrypt(encrypted_part, key=second_pbkdf2_part)
test_hash = pbkdf2(first_pbkdf2_part, key=cnonce + server_challenge)
compare test_hash with transmitted pbkdf2_hash
"""
# log.debug("check_sec... | python | def check_secure_js_login(secure_password, encrypted_part, server_challenge):
"""
first_pbkdf2_part = xor_decrypt(encrypted_part, key=second_pbkdf2_part)
test_hash = pbkdf2(first_pbkdf2_part, key=cnonce + server_challenge)
compare test_hash with transmitted pbkdf2_hash
"""
# log.debug("check_sec... | [
"def",
"check_secure_js_login",
"(",
"secure_password",
",",
"encrypted_part",
",",
"server_challenge",
")",
":",
"# log.debug(\"check_secure_js_login(secure_password='%s', encrypted_part='%s', server_challenge='%s')\",",
"# secure_password, encrypted_part, server_challenge",
"# )",
"p... | first_pbkdf2_part = xor_decrypt(encrypted_part, key=second_pbkdf2_part)
test_hash = pbkdf2(first_pbkdf2_part, key=cnonce + server_challenge)
compare test_hash with transmitted pbkdf2_hash | [
"first_pbkdf2_part",
"=",
"xor_decrypt",
"(",
"encrypted_part",
"key",
"=",
"second_pbkdf2_part",
")",
"test_hash",
"=",
"pbkdf2",
"(",
"first_pbkdf2_part",
"key",
"=",
"cnonce",
"+",
"server_challenge",
")",
"compare",
"test_hash",
"with",
"transmitted",
"pbkdf2_hash... | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L427-L454 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | XorCryptor.xor | def xor(self, txt, key):
"""
>>> crypted = XorCryptor().xor(b"1234", b"ABCD")
>>> crypted == b'pppp'
True
>>> txt = XorCryptor().xor(b'pppp', b"ABCD")
>>> txt == b'1234'
True
"""
assert isinstance(txt, six.binary_type), "txt: %s is not binary type!... | python | def xor(self, txt, key):
"""
>>> crypted = XorCryptor().xor(b"1234", b"ABCD")
>>> crypted == b'pppp'
True
>>> txt = XorCryptor().xor(b'pppp', b"ABCD")
>>> txt == b'1234'
True
"""
assert isinstance(txt, six.binary_type), "txt: %s is not binary type!... | [
"def",
"xor",
"(",
"self",
",",
"txt",
",",
"key",
")",
":",
"assert",
"isinstance",
"(",
"txt",
",",
"six",
".",
"binary_type",
")",
",",
"\"txt: %s is not binary type!\"",
"%",
"repr",
"(",
"txt",
")",
"assert",
"isinstance",
"(",
"key",
",",
"six",
... | >>> crypted = XorCryptor().xor(b"1234", b"ABCD")
>>> crypted == b'pppp'
True
>>> txt = XorCryptor().xor(b'pppp', b"ABCD")
>>> txt == b'1234'
True | [
">>>",
"crypted",
"=",
"XorCryptor",
"()",
".",
"xor",
"(",
"b",
"1234",
"b",
"ABCD",
")",
">>>",
"crypted",
"==",
"b",
"pppp",
"True",
">>>",
"txt",
"=",
"XorCryptor",
"()",
".",
"xor",
"(",
"b",
"pppp",
"b",
"ABCD",
")",
">>>",
"txt",
"==",
"b"... | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L235-L256 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | XorCryptor.encrypt | def encrypt(self, txt, key):
"""
XOR ciphering with a PBKDF2 checksum
"""
# log.debug("encrypt(txt='%s', key='%s')", txt, key)
assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
assert isinstance(key, six.text_type), "key: %s is not text type!"... | python | def encrypt(self, txt, key):
"""
XOR ciphering with a PBKDF2 checksum
"""
# log.debug("encrypt(txt='%s', key='%s')", txt, key)
assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
assert isinstance(key, six.text_type), "key: %s is not text type!"... | [
"def",
"encrypt",
"(",
"self",
",",
"txt",
",",
"key",
")",
":",
"# log.debug(\"encrypt(txt='%s', key='%s')\", txt, key)",
"assert",
"isinstance",
"(",
"txt",
",",
"six",
".",
"text_type",
")",
",",
"\"txt: %s is not text type!\"",
"%",
"repr",
"(",
"txt",
")",
... | XOR ciphering with a PBKDF2 checksum | [
"XOR",
"ciphering",
"with",
"a",
"PBKDF2",
"checksum"
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L258-L276 |
discontinue/django-secure-js-login | secure_js_login/utils/crypt.py | XorCryptor.decrypt | def decrypt(self, txt, key):
"""
1. Decrypt a XOR crypted String.
2. Compare the inserted SHA salt-hash checksum.
"""
# log.debug("decrypt(txt='%s', key='%s')", txt, key)
assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
assert isinsta... | python | def decrypt(self, txt, key):
"""
1. Decrypt a XOR crypted String.
2. Compare the inserted SHA salt-hash checksum.
"""
# log.debug("decrypt(txt='%s', key='%s')", txt, key)
assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
assert isinsta... | [
"def",
"decrypt",
"(",
"self",
",",
"txt",
",",
"key",
")",
":",
"# log.debug(\"decrypt(txt='%s', key='%s')\", txt, key)",
"assert",
"isinstance",
"(",
"txt",
",",
"six",
".",
"text_type",
")",
",",
"\"txt: %s is not text type!\"",
"%",
"repr",
"(",
"txt",
")",
... | 1. Decrypt a XOR crypted String.
2. Compare the inserted SHA salt-hash checksum. | [
"1",
".",
"Decrypt",
"a",
"XOR",
"crypted",
"String",
".",
"2",
".",
"Compare",
"the",
"inserted",
"SHA",
"salt",
"-",
"hash",
"checksum",
"."
] | train | https://github.com/discontinue/django-secure-js-login/blob/4bfc592c48f381de115e592e721f31d2eb915968/secure_js_login/utils/crypt.py#L279-L318 |
nrcharles/caelum | caelum/noaa.py | forecast | def forecast(place, series=True):
"""NOAA weather forecast for a location"""
lat, lon = place
url = "http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?" + \
"whichClient=NDFDgen&" + "lat=%s&lon=%s&" % (lat, lon) + \
"Unit=e&temp=temp&wspd=wspd&sky=sky&wx=wx&rh=rh&" + \
... | python | def forecast(place, series=True):
"""NOAA weather forecast for a location"""
lat, lon = place
url = "http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?" + \
"whichClient=NDFDgen&" + "lat=%s&lon=%s&" % (lat, lon) + \
"Unit=e&temp=temp&wspd=wspd&sky=sky&wx=wx&rh=rh&" + \
... | [
"def",
"forecast",
"(",
"place",
",",
"series",
"=",
"True",
")",
":",
"lat",
",",
"lon",
"=",
"place",
"url",
"=",
"\"http://graphical.weather.gov/xml/SOAP_server/ndfdXMLclient.php?\"",
"+",
"\"whichClient=NDFDgen&\"",
"+",
"\"lat=%s&lon=%s&\"",
"%",
"(",
"lat",
",... | NOAA weather forecast for a location | [
"NOAA",
"weather",
"forecast",
"for",
"a",
"location"
] | train | https://github.com/nrcharles/caelum/blob/9a8e65806385978556d7bb2e6870f003ff82023e/caelum/noaa.py#L10-L39 |
nrcharles/caelum | caelum/noaa.py | _cast_float | def _cast_float(temp_dt):
"""returns utc timestamp"""
if type(temp_dt) == str:
fmt = '%Y-%m-%dT%H:%M:00'
base_dt = temp_dt[0:19]
tz_offset = eval(temp_dt[19:22])
temp_dt = datetime.datetime.strptime(base_dt, fmt) - \
datetime.timedelta(hours=tz_offset)
return ... | python | def _cast_float(temp_dt):
"""returns utc timestamp"""
if type(temp_dt) == str:
fmt = '%Y-%m-%dT%H:%M:00'
base_dt = temp_dt[0:19]
tz_offset = eval(temp_dt[19:22])
temp_dt = datetime.datetime.strptime(base_dt, fmt) - \
datetime.timedelta(hours=tz_offset)
return ... | [
"def",
"_cast_float",
"(",
"temp_dt",
")",
":",
"if",
"type",
"(",
"temp_dt",
")",
"==",
"str",
":",
"fmt",
"=",
"'%Y-%m-%dT%H:%M:00'",
"base_dt",
"=",
"temp_dt",
"[",
"0",
":",
"19",
"]",
"tz_offset",
"=",
"eval",
"(",
"temp_dt",
"[",
"19",
":",
"22... | returns utc timestamp | [
"returns",
"utc",
"timestamp"
] | train | https://github.com/nrcharles/caelum/blob/9a8e65806385978556d7bb2e6870f003ff82023e/caelum/noaa.py#L46-L54 |
nrcharles/caelum | caelum/noaa.py | herp_derp_interp | def herp_derp_interp(place):
"""simple interpolation of GFS forecast"""
lat, lon = place
#begin=2014-02-14T00%3A00%3A00&end=2018-02-22T00%3A00%3A00
fmt = '%Y-%m-%dT00:00:00'
fmt = '%Y-%m-%dT%H:%M:00'
begin = (datetime.datetime.now()-datetime.timedelta(hours=12)).strftime(fmt)
#end=(datetime.... | python | def herp_derp_interp(place):
"""simple interpolation of GFS forecast"""
lat, lon = place
#begin=2014-02-14T00%3A00%3A00&end=2018-02-22T00%3A00%3A00
fmt = '%Y-%m-%dT00:00:00'
fmt = '%Y-%m-%dT%H:%M:00'
begin = (datetime.datetime.now()-datetime.timedelta(hours=12)).strftime(fmt)
#end=(datetime.... | [
"def",
"herp_derp_interp",
"(",
"place",
")",
":",
"lat",
",",
"lon",
"=",
"place",
"#begin=2014-02-14T00%3A00%3A00&end=2018-02-22T00%3A00%3A00",
"fmt",
"=",
"'%Y-%m-%dT00:00:00'",
"fmt",
"=",
"'%Y-%m-%dT%H:%M:00'",
"begin",
"=",
"(",
"datetime",
".",
"datetime",
".",... | simple interpolation of GFS forecast | [
"simple",
"interpolation",
"of",
"GFS",
"forecast"
] | train | https://github.com/nrcharles/caelum/blob/9a8e65806385978556d7bb2e6870f003ff82023e/caelum/noaa.py#L56-L99 |
mitsei/dlkit | dlkit/json_/authentication/managers.py | AuthenticationManager.get_agent_lookup_session | def get_agent_lookup_session(self):
"""Gets the ``OsidSession`` associated with the agent lookup service.
return: (osid.authentication.AgentLookupSession) - an
``AgentLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_... | python | def get_agent_lookup_session(self):
"""Gets the ``OsidSession`` associated with the agent lookup service.
return: (osid.authentication.AgentLookupSession) - an
``AgentLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_... | [
"def",
"get_agent_lookup_session",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"supports_agent_lookup",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"# pylint: disable=no-member",
"return",
"sessions",
".",
"AgentLookupSession",
"(",
"run... | Gets the ``OsidSession`` associated with the agent lookup service.
return: (osid.authentication.AgentLookupSession) - an
``AgentLookupSession``
raise: OperationFailed - unable to complete request
raise: Unimplemented - ``supports_agent_lookup()`` is ``false``
*complian... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"agent",
"lookup",
"service",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authentication/managers.py#L150-L164 |
mitsei/dlkit | dlkit/json_/authentication/managers.py | AuthenticationManager.get_agent_lookup_session_for_agency | def get_agent_lookup_session_for_agency(self, agency_id):
"""Gets the ``OsidSession`` associated with the agent lookup service for the given agency.
arg: agency_id (osid.id.Id): the ``Id`` of the agency
return: (osid.authentication.AgentLookupSession) - ``an
_agent_lookup_ses... | python | def get_agent_lookup_session_for_agency(self, agency_id):
"""Gets the ``OsidSession`` associated with the agent lookup service for the given agency.
arg: agency_id (osid.id.Id): the ``Id`` of the agency
return: (osid.authentication.AgentLookupSession) - ``an
_agent_lookup_ses... | [
"def",
"get_agent_lookup_session_for_agency",
"(",
"self",
",",
"agency_id",
")",
":",
"if",
"not",
"self",
".",
"supports_agent_lookup",
"(",
")",
":",
"raise",
"errors",
".",
"Unimplemented",
"(",
")",
"##",
"# Also include check to see if the catalog Id is found othe... | Gets the ``OsidSession`` associated with the agent lookup service for the given agency.
arg: agency_id (osid.id.Id): the ``Id`` of the agency
return: (osid.authentication.AgentLookupSession) - ``an
_agent_lookup_session``
raise: NotFound - ``agency_id`` not found
rai... | [
"Gets",
"the",
"OsidSession",
"associated",
"with",
"the",
"agent",
"lookup",
"service",
"for",
"the",
"given",
"agency",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/authentication/managers.py#L170-L192 |
mitsei/dlkit | dlkit/primordium/locale/types/calendar.py | get_type_data | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
if name in CALENDAR_TYPES:
domain = 'Calendar Types'
calendar_name = CALENDAR_TYPES[name]
elif name in ANCIENT_CALENDAR_TYPES:... | python | def get_type_data(name):
"""Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type
"""
name = name.upper()
if name in CALENDAR_TYPES:
domain = 'Calendar Types'
calendar_name = CALENDAR_TYPES[name]
elif name in ANCIENT_CALENDAR_TYPES:... | [
"def",
"get_type_data",
"(",
"name",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"if",
"name",
"in",
"CALENDAR_TYPES",
":",
"domain",
"=",
"'Calendar Types'",
"calendar_name",
"=",
"CALENDAR_TYPES",
"[",
"name",
"]",
"elif",
"name",
"in",
"ANCIE... | Return dictionary representation of type.
Can be used to initialize primordium.type.primitives.Type | [
"Return",
"dictionary",
"representation",
"of",
"type",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/primordium/locale/types/calendar.py#L274-L301 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | write_index | def write_index(path,index_file,verbose=False,samtools=False):
""" Index file is a gzipped TSV file with these fields:
1. qname
2. target range
3. bgzf file block start
4. bgzf inner block start
5. aligned base count
6. flag
:param path: bamfile
:param index_file: bam index to write
:param verbose... | python | def write_index(path,index_file,verbose=False,samtools=False):
""" Index file is a gzipped TSV file with these fields:
1. qname
2. target range
3. bgzf file block start
4. bgzf inner block start
5. aligned base count
6. flag
:param path: bamfile
:param index_file: bam index to write
:param verbose... | [
"def",
"write_index",
"(",
"path",
",",
"index_file",
",",
"verbose",
"=",
"False",
",",
"samtools",
"=",
"False",
")",
":",
"if",
"verbose",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"scanning for primaries\\n\"",
")",
"reads",
"=",
"{",
"}",
"z",... | Index file is a gzipped TSV file with these fields:
1. qname
2. target range
3. bgzf file block start
4. bgzf inner block start
5. aligned base count
6. flag
:param path: bamfile
:param index_file: bam index to write
:param verbose: default False
:param samtools: use samtools default False
:type... | [
"Index",
"file",
"is",
"a",
"gzipped",
"TSV",
"file",
"with",
"these",
"fields",
":"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L225-L347 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.check_ordered | def check_ordered(self):
""" True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false
:return: is it ordered?
:rtype: bool
"""
sys.stderr.write("error unimplemented check_ordered\n")
sys.exit()
seen_chrs = set()
curr_chr ... | python | def check_ordered(self):
""" True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false
:return: is it ordered?
:rtype: bool
"""
sys.stderr.write("error unimplemented check_ordered\n")
sys.exit()
seen_chrs = set()
curr_chr ... | [
"def",
"check_ordered",
"(",
"self",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented check_ordered\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"seen_chrs",
"=",
"set",
"(",
")",
"curr_chr",
"=",
"None",
"prevstart",
"=",
"0",
"for",... | True if each chromosome is listed together as a chunk and if the range starts go from smallest to largest otherwise false
:return: is it ordered?
:rtype: bool | [
"True",
"if",
"each",
"chromosome",
"is",
"listed",
"together",
"as",
"a",
"chunk",
"and",
"if",
"the",
"range",
"starts",
"go",
"from",
"smallest",
"to",
"largest",
"otherwise",
"false"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L58-L79 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_coords_by_name | def get_coords_by_name(self,name):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_coords_by_name\n")
sys.exit()
return [[self._lines[x]['filestart'],self._lines[x]['innerstart']] for x in self._queries[self._name_to_num[name]]] | python | def get_coords_by_name(self,name):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_coords_by_name\n")
sys.exit()
return [[self._lines[x]['filestart'],self._lines[x]['innerstart']] for x in self._queries[self._name_to_num[name]]] | [
"def",
"get_coords_by_name",
"(",
"self",
",",
"name",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented get_coords_by_name\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"return",
"[",
"[",
"self",
".",
"_lines",
"[",
"x",
"]",
"[",
"... | .. warning:: not implemented | [
"..",
"warning",
"::",
"not",
"implemented"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L89-L95 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_longest_target_alignment_coords_by_name | def get_longest_target_alignment_coords_by_name(self,name):
"""For a name get the best alignment
:return: [filebyte,innerbyte] describing the to distance the zipped block start, and the distance within the unzipped block
:rtype: list
"""
longest = -1
coord = None
#for x in self._queries[sel... | python | def get_longest_target_alignment_coords_by_name(self,name):
"""For a name get the best alignment
:return: [filebyte,innerbyte] describing the to distance the zipped block start, and the distance within the unzipped block
:rtype: list
"""
longest = -1
coord = None
#for x in self._queries[sel... | [
"def",
"get_longest_target_alignment_coords_by_name",
"(",
"self",
",",
"name",
")",
":",
"longest",
"=",
"-",
"1",
"coord",
"=",
"None",
"#for x in self._queries[self._name_to_num[name]]:",
"for",
"line",
"in",
"[",
"self",
".",
"_lines",
"[",
"x",
"]",
"for",
... | For a name get the best alignment
:return: [filebyte,innerbyte] describing the to distance the zipped block start, and the distance within the unzipped block
:rtype: list | [
"For",
"a",
"name",
"get",
"the",
"best",
"alignment"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L97-L111 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_index_line | def get_index_line(self,lnum):
""" Take the 1-indexed line number and return its index information"""
if lnum < 1:
sys.stderr.write("ERROR: line number should be greater than zero\n")
sys.exit()
elif lnum > len(self._lines):
sys.stderr.write("ERROR: too far this line nuber is not in index\... | python | def get_index_line(self,lnum):
""" Take the 1-indexed line number and return its index information"""
if lnum < 1:
sys.stderr.write("ERROR: line number should be greater than zero\n")
sys.exit()
elif lnum > len(self._lines):
sys.stderr.write("ERROR: too far this line nuber is not in index\... | [
"def",
"get_index_line",
"(",
"self",
",",
"lnum",
")",
":",
"if",
"lnum",
"<",
"1",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"ERROR: line number should be greater than zero\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"elif",
"lnum",
">",
"len",
"(",
... | Take the 1-indexed line number and return its index information | [
"Take",
"the",
"1",
"-",
"indexed",
"line",
"number",
"and",
"return",
"its",
"index",
"information"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L113-L121 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_coord_line_number | def get_coord_line_number(self,coord):
"""return the one-indexed line number given the coordinates"""
if coord[0] in self._coords:
if coord[1] in self._coords[coord[0]]:
return self._coords[coord[0]][coord[1]]
return None | python | def get_coord_line_number(self,coord):
"""return the one-indexed line number given the coordinates"""
if coord[0] in self._coords:
if coord[1] in self._coords[coord[0]]:
return self._coords[coord[0]][coord[1]]
return None | [
"def",
"get_coord_line_number",
"(",
"self",
",",
"coord",
")",
":",
"if",
"coord",
"[",
"0",
"]",
"in",
"self",
".",
"_coords",
":",
"if",
"coord",
"[",
"1",
"]",
"in",
"self",
".",
"_coords",
"[",
"coord",
"[",
"0",
"]",
"]",
":",
"return",
"se... | return the one-indexed line number given the coordinates | [
"return",
"the",
"one",
"-",
"indexed",
"line",
"number",
"given",
"the",
"coordinates"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L123-L128 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_unaligned_lines | def get_unaligned_lines(self):
"""get the lines that are not aligned"""
sys.stderr.write("error unimplemented get_unaligned_lines\n")
sys.exit()
return [self._lines[x-1] for x in self._unaligned] | python | def get_unaligned_lines(self):
"""get the lines that are not aligned"""
sys.stderr.write("error unimplemented get_unaligned_lines\n")
sys.exit()
return [self._lines[x-1] for x in self._unaligned] | [
"def",
"get_unaligned_lines",
"(",
"self",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented get_unaligned_lines\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"return",
"[",
"self",
".",
"_lines",
"[",
"x",
"-",
"1",
"]",
"for",
"x",
... | get the lines that are not aligned | [
"get",
"the",
"lines",
"that",
"are",
"not",
"aligned"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L130-L134 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_unaligned_start_coord | def get_unaligned_start_coord(self):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_unaligned_start_coord\n")
sys.exit()
if len(self._unaligned)==0: return None
return [self._lines[self._unaligned[0]-1]['filestart'],self._lines[self._unaligned[0]-1]['innerstar... | python | def get_unaligned_start_coord(self):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_unaligned_start_coord\n")
sys.exit()
if len(self._unaligned)==0: return None
return [self._lines[self._unaligned[0]-1]['filestart'],self._lines[self._unaligned[0]-1]['innerstar... | [
"def",
"get_unaligned_start_coord",
"(",
"self",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented get_unaligned_start_coord\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"if",
"len",
"(",
"self",
".",
"_unaligned",
")",
"==",
"0",
":",
"... | .. warning:: not implemented | [
"..",
"warning",
"::",
"not",
"implemented"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L136-L143 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_range_start_coord | def get_range_start_coord(self,rng):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_range_start_coord\n")
sys.exit()
if rng.chr not in self._chrs: return None
for l in [self._lines[x-1] for x in self._chrs[rng.chr]]:
####
y = l['rng']
c = y.c... | python | def get_range_start_coord(self,rng):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_range_start_coord\n")
sys.exit()
if rng.chr not in self._chrs: return None
for l in [self._lines[x-1] for x in self._chrs[rng.chr]]:
####
y = l['rng']
c = y.c... | [
"def",
"get_range_start_coord",
"(",
"self",
",",
"rng",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented get_range_start_coord\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"if",
"rng",
".",
"chr",
"not",
"in",
"self",
".",
"_chrs",
"... | .. warning:: not implemented | [
"..",
"warning",
"::",
"not",
"implemented"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L145-L160 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/bamindex.py | BAMIndex.get_range_start_line_number | def get_range_start_line_number(self,rng):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_range_start_line\n")
sys.exit()
for i in range(0,len(self._lines)):
if rng.cmp(self._lines[i]['rng'])==0: return i+1
return None | python | def get_range_start_line_number(self,rng):
"""
.. warning:: not implemented
"""
sys.stderr.write("error unimplemented get_range_start_line\n")
sys.exit()
for i in range(0,len(self._lines)):
if rng.cmp(self._lines[i]['rng'])==0: return i+1
return None | [
"def",
"get_range_start_line_number",
"(",
"self",
",",
"rng",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"error unimplemented get_range_start_line\\n\"",
")",
"sys",
".",
"exit",
"(",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"s... | .. warning:: not implemented | [
"..",
"warning",
"::",
"not",
"implemented"
] | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/bamindex.py#L163-L171 |
jason-weirather/py-seq-tools | seqtools/format/sam/bam/__init__.py | _bin_to_extra | def _bin_to_extra(extra_bytes):
"""Pre all the reamining bytes of an entry
Post an array of
1. A dict keyed by Tag with {'type':,'value':} where value is a string unless type is i
2. A string of the remainder
"""
#global _bam_value_type
extra = StringIO(extra_bytes)
tags = {}
rem = ''
while extra... | python | def _bin_to_extra(extra_bytes):
"""Pre all the reamining bytes of an entry
Post an array of
1. A dict keyed by Tag with {'type':,'value':} where value is a string unless type is i
2. A string of the remainder
"""
#global _bam_value_type
extra = StringIO(extra_bytes)
tags = {}
rem = ''
while extra... | [
"def",
"_bin_to_extra",
"(",
"extra_bytes",
")",
":",
"#global _bam_value_type",
"extra",
"=",
"StringIO",
"(",
"extra_bytes",
")",
"tags",
"=",
"{",
"}",
"rem",
"=",
"''",
"while",
"extra",
".",
"tell",
"(",
")",
"<",
"len",
"(",
"extra_bytes",
")",
":"... | Pre all the reamining bytes of an entry
Post an array of
1. A dict keyed by Tag with {'type':,'value':} where value is a string unless type is i
2. A string of the remainder | [
"Pre",
"all",
"the",
"reamining",
"bytes",
"of",
"an",
"entry",
"Post",
"an",
"array",
"of",
"1",
".",
"A",
"dict",
"keyed",
"by",
"Tag",
"with",
"{",
"type",
":",
"value",
":",
"}",
"where",
"value",
"is",
"a",
"string",
"unless",
"type",
"is",
"i... | train | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/format/sam/bam/__init__.py#L328-L379 |
ytjia/utils-py | utils_py/TimeRange.py | TimeRange.lie_between | def lie_between(self, target_time_range):
"""
判断是否落在目标时间区间内
:param target_time_range: 目标时间区间
:return: True or False
"""
if self.begin_dt >= target_time_range.begin_dt and self.end_dt <= \
target_time_range.end_dt:
return True
else:
... | python | def lie_between(self, target_time_range):
"""
判断是否落在目标时间区间内
:param target_time_range: 目标时间区间
:return: True or False
"""
if self.begin_dt >= target_time_range.begin_dt and self.end_dt <= \
target_time_range.end_dt:
return True
else:
... | [
"def",
"lie_between",
"(",
"self",
",",
"target_time_range",
")",
":",
"if",
"self",
".",
"begin_dt",
">=",
"target_time_range",
".",
"begin_dt",
"and",
"self",
".",
"end_dt",
"<=",
"target_time_range",
".",
"end_dt",
":",
"return",
"True",
"else",
":",
"ret... | 判断是否落在目标时间区间内
:param target_time_range: 目标时间区间
:return: True or False | [
"判断是否落在目标时间区间内",
":",
"param",
"target_time_range",
":",
"目标时间区间",
":",
"return",
":",
"True",
"or",
"False"
] | train | https://github.com/ytjia/utils-py/blob/68039b367e2e38fdecf234ecc625406b9e203ec0/utils_py/TimeRange.py#L21-L31 |
ytjia/utils-py | utils_py/TimeRange.py | TimeRange.do_intersect | def do_intersect(self, another_time_range):
"""
判断与另一时间区间是否有重叠
:param another_time_range:
:return: True or False
"""
if self.begin_dt > another_time_range.end_dt or self.end_dt < \
another_time_range.begin_dt:
return False
else:
... | python | def do_intersect(self, another_time_range):
"""
判断与另一时间区间是否有重叠
:param another_time_range:
:return: True or False
"""
if self.begin_dt > another_time_range.end_dt or self.end_dt < \
another_time_range.begin_dt:
return False
else:
... | [
"def",
"do_intersect",
"(",
"self",
",",
"another_time_range",
")",
":",
"if",
"self",
".",
"begin_dt",
">",
"another_time_range",
".",
"end_dt",
"or",
"self",
".",
"end_dt",
"<",
"another_time_range",
".",
"begin_dt",
":",
"return",
"False",
"else",
":",
"r... | 判断与另一时间区间是否有重叠
:param another_time_range:
:return: True or False | [
"判断与另一时间区间是否有重叠",
":",
"param",
"another_time_range",
":",
":",
"return",
":",
"True",
"or",
"False"
] | train | https://github.com/ytjia/utils-py/blob/68039b367e2e38fdecf234ecc625406b9e203ec0/utils_py/TimeRange.py#L33-L43 |
Vagrants/blackbird | blackbird/plugins/base.py | JobBase.enqueue | def enqueue(self, item, queue=None):
"""
Enqueue items.
If you define "self.filter" (sequence),
this method put the item to queue after filtering.
"self.filter" operates as blacklist.
This method expects that
"item" argument has dict type "data" attribute.
... | python | def enqueue(self, item, queue=None):
"""
Enqueue items.
If you define "self.filter" (sequence),
this method put the item to queue after filtering.
"self.filter" operates as blacklist.
This method expects that
"item" argument has dict type "data" attribute.
... | [
"def",
"enqueue",
"(",
"self",
",",
"item",
",",
"queue",
"=",
"None",
")",
":",
"if",
"queue",
"is",
"None",
":",
"queue",
"=",
"self",
".",
"queue",
"is_enqueue_item",
"=",
"True",
"if",
"self",
".",
"invalid_key_list",
"is",
"not",
"None",
":",
"f... | Enqueue items.
If you define "self.filter" (sequence),
this method put the item to queue after filtering.
"self.filter" operates as blacklist.
This method expects that
"item" argument has dict type "data" attribute. | [
"Enqueue",
"items",
".",
"If",
"you",
"define",
"self",
".",
"filter",
"(",
"sequence",
")",
"this",
"method",
"put",
"the",
"item",
"to",
"queue",
"after",
"filtering",
".",
"self",
".",
"filter",
"operates",
"as",
"blacklist",
"."
] | train | https://github.com/Vagrants/blackbird/blob/3b38cd5650caae362e0668dbd38bf8f88233e079/blackbird/plugins/base.py#L31-L66 |
Vagrants/blackbird | blackbird/plugins/base.py | ItemBase._generate | def _generate(self):
u"""overrided in each modules."""
self._data['key'] = self.key
self._data['value'] = self.value
self._data['host'] = self.host
self._data['clock'] = self.clock | python | def _generate(self):
u"""overrided in each modules."""
self._data['key'] = self.key
self._data['value'] = self.value
self._data['host'] = self.host
self._data['clock'] = self.clock | [
"def",
"_generate",
"(",
"self",
")",
":",
"self",
".",
"_data",
"[",
"'key'",
"]",
"=",
"self",
".",
"key",
"self",
".",
"_data",
"[",
"'value'",
"]",
"=",
"self",
".",
"value",
"self",
".",
"_data",
"[",
"'host'",
"]",
"=",
"self",
".",
"host",... | u"""overrided in each modules. | [
"u",
"overrided",
"in",
"each",
"modules",
"."
] | train | https://github.com/Vagrants/blackbird/blob/3b38cd5650caae362e0668dbd38bf8f88233e079/blackbird/plugins/base.py#L89-L95 |
Vagrants/blackbird | blackbird/plugins/base.py | ItemBase.__set_timestamp | def __set_timestamp(self, clock):
"""
If "clock" is None, set the time now.
This function is called self.__init__()
"""
if clock is None:
unix_timestamp = time.mktime(
datetime.datetime.now().utctimetuple()
)
timestamp = int(uni... | python | def __set_timestamp(self, clock):
"""
If "clock" is None, set the time now.
This function is called self.__init__()
"""
if clock is None:
unix_timestamp = time.mktime(
datetime.datetime.now().utctimetuple()
)
timestamp = int(uni... | [
"def",
"__set_timestamp",
"(",
"self",
",",
"clock",
")",
":",
"if",
"clock",
"is",
"None",
":",
"unix_timestamp",
"=",
"time",
".",
"mktime",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"utctimetuple",
"(",
")",
")",
"timestamp",
"=",... | If "clock" is None, set the time now.
This function is called self.__init__() | [
"If",
"clock",
"is",
"None",
"set",
"the",
"time",
"now",
".",
"This",
"function",
"is",
"called",
"self",
".",
"__init__",
"()"
] | train | https://github.com/Vagrants/blackbird/blob/3b38cd5650caae362e0668dbd38bf8f88233e079/blackbird/plugins/base.py#L97-L111 |
tommyod/streprogen | streprogen/utils.py | compose | def compose(first_func, second_func):
"""
Compose two functions. Documentation is retrieved from the first one.
Parameters
----------
first_func
The first, main, function.
second_func
The second, (less important) function.
Returns
function
A new function.
... | python | def compose(first_func, second_func):
"""
Compose two functions. Documentation is retrieved from the first one.
Parameters
----------
first_func
The first, main, function.
second_func
The second, (less important) function.
Returns
function
A new function.
... | [
"def",
"compose",
"(",
"first_func",
",",
"second_func",
")",
":",
"@",
"wraps",
"(",
"first_func",
")",
"def",
"composed_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"second_func",
"(",
"(",
"first_func",
"(",
"*",
"args",
","... | Compose two functions. Documentation is retrieved from the first one.
Parameters
----------
first_func
The first, main, function.
second_func
The second, (less important) function.
Returns
function
A new function.
------- | [
"Compose",
"two",
"functions",
".",
"Documentation",
"is",
"retrieved",
"from",
"the",
"first",
"one",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L10-L33 |
tommyod/streprogen | streprogen/utils.py | escape_string | def escape_string(text):
"""Remove problematic characters.
Parameters
----------
text
A string with potentially problematic characters.
Returns
-------
string
The text with characters removed.
Examples
-------
>>> s = r'hello_world$here'
>>> escape_string(... | python | def escape_string(text):
"""Remove problematic characters.
Parameters
----------
text
A string with potentially problematic characters.
Returns
-------
string
The text with characters removed.
Examples
-------
>>> s = r'hello_world$here'
>>> escape_string(... | [
"def",
"escape_string",
"(",
"text",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"text",
"TO_REMOVE",
"=",
"[",
"r'&'",
",",
"r'%'",
",",
"r'$'",
",",
"r'#'",
",",
"r'_'",
",",
"r'{'",
",",
"r'}'",
",",
"r'~'",
",",
"r'^'",
",",
"r'\\\\'",... | Remove problematic characters.
Parameters
----------
text
A string with potentially problematic characters.
Returns
-------
string
The text with characters removed.
Examples
-------
>>> s = r'hello_world$here'
>>> escape_string(s) == r'helloworldhere'
True | [
"Remove",
"problematic",
"characters",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L35-L64 |
tommyod/streprogen | streprogen/utils.py | chunker | def chunker(iterable, size=5, fill=''):
"""Chunk the iterable.
Parameters
----------
iterable
A list.
size
The size of the chunks.
fill
Fill value if the chunk is not of length 'size'.
Yields
-------
chunk
A chunk of length 'size'.
Examples
... | python | def chunker(iterable, size=5, fill=''):
"""Chunk the iterable.
Parameters
----------
iterable
A list.
size
The size of the chunks.
fill
Fill value if the chunk is not of length 'size'.
Yields
-------
chunk
A chunk of length 'size'.
Examples
... | [
"def",
"chunker",
"(",
"iterable",
",",
"size",
"=",
"5",
",",
"fill",
"=",
"''",
")",
":",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"iterable",
")",
"//",
"size",
"+",
"1",
")",
":",
"to_yield",
"=",
"iterable",
"[",
"index",
... | Chunk the iterable.
Parameters
----------
iterable
A list.
size
The size of the chunks.
fill
Fill value if the chunk is not of length 'size'.
Yields
-------
chunk
A chunk of length 'size'.
Examples
-------
>>> l = list(range(6))
>>> c... | [
"Chunk",
"the",
"iterable",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L67-L107 |
tommyod/streprogen | streprogen/utils.py | round_to_nearest | def round_to_nearest(number, nearest=1):
"""Round 'number' to the nearest multiple of 'nearest'.
Parameters
----------
number
A real number to round.
nearest
Number to round to closes multiple of.
Returns
-------
rounded
A rounded number.
Examples
----... | python | def round_to_nearest(number, nearest=1):
"""Round 'number' to the nearest multiple of 'nearest'.
Parameters
----------
number
A real number to round.
nearest
Number to round to closes multiple of.
Returns
-------
rounded
A rounded number.
Examples
----... | [
"def",
"round_to_nearest",
"(",
"number",
",",
"nearest",
"=",
"1",
")",
":",
"result",
"=",
"nearest",
"*",
"round",
"(",
"number",
"/",
"nearest",
")",
"if",
"result",
"%",
"1",
"==",
"0",
":",
"return",
"int",
"(",
"result",
")",
"if",
"nearest",
... | Round 'number' to the nearest multiple of 'nearest'.
Parameters
----------
number
A real number to round.
nearest
Number to round to closes multiple of.
Returns
-------
rounded
A rounded number.
Examples
-------
>>> round_to_nearest(6.8, nearest = 2.5)... | [
"Round",
"number",
"to",
"the",
"nearest",
"multiple",
"of",
"nearest",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L136-L167 |
tommyod/streprogen | streprogen/utils.py | all_equal | def all_equal(iterable):
"""Checks whether all items in an iterable are equal.
Parameters
----------
iterable
An iterable, e.g. a string og a list.
Returns
-------
boolean
True or False.
Examples
-------
>>> all_equal([2, 2, 2])
True
>>> all_equal([... | python | def all_equal(iterable):
"""Checks whether all items in an iterable are equal.
Parameters
----------
iterable
An iterable, e.g. a string og a list.
Returns
-------
boolean
True or False.
Examples
-------
>>> all_equal([2, 2, 2])
True
>>> all_equal([... | [
"def",
"all_equal",
"(",
"iterable",
")",
":",
"if",
"len",
"(",
"iterable",
")",
"in",
"[",
"0",
",",
"1",
"]",
":",
"return",
"False",
"first",
"=",
"iterable",
"[",
"0",
"]",
"return",
"all",
"(",
"[",
"first",
"==",
"i",
"for",
"i",
"in",
"... | Checks whether all items in an iterable are equal.
Parameters
----------
iterable
An iterable, e.g. a string og a list.
Returns
-------
boolean
True or False.
Examples
-------
>>> all_equal([2, 2, 2])
True
>>> all_equal([1, 2, 3])
False | [
"Checks",
"whether",
"all",
"items",
"in",
"an",
"iterable",
"are",
"equal",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L170-L194 |
tommyod/streprogen | streprogen/utils.py | min_between | def min_between(min_reps=3, max_reps=8, percentile=0.33):
"""Function to decide the minimum number of reps to perform
given `min_reps` and `max_rep`.
Parameters
----------
min_reps
The minimum number of repeitions.
max_reps
The maximum number of repetitions.
percentile
... | python | def min_between(min_reps=3, max_reps=8, percentile=0.33):
"""Function to decide the minimum number of reps to perform
given `min_reps` and `max_rep`.
Parameters
----------
min_reps
The minimum number of repeitions.
max_reps
The maximum number of repetitions.
percentile
... | [
"def",
"min_between",
"(",
"min_reps",
"=",
"3",
",",
"max_reps",
"=",
"8",
",",
"percentile",
"=",
"0.33",
")",
":",
"higher_limit",
"=",
"min_reps",
"+",
"(",
"max_reps",
"-",
"min_reps",
")",
"*",
"percentile",
"return",
"min_reps",
",",
"math",
".",
... | Function to decide the minimum number of reps to perform
given `min_reps` and `max_rep`.
Parameters
----------
min_reps
The minimum number of repeitions.
max_reps
The maximum number of repetitions.
percentile
The percentile to cap at.
Return
-------
(low, ... | [
"Function",
"to",
"decide",
"the",
"minimum",
"number",
"of",
"reps",
"to",
"perform",
"given",
"min_reps",
"and",
"max_rep",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L197-L224 |
tommyod/streprogen | streprogen/utils.py | generate_reps | def generate_reps(min_reps=3, max_reps=8, total=25, existing=None):
"""Generate 'total' repetitions between 'min_reps' and 'max_reps',
if existing is given (not None), then some repetitions are already
drawn.
Parameters
----------
min_reps
Lower limit for the repetitions dawing, e.g. 3.... | python | def generate_reps(min_reps=3, max_reps=8, total=25, existing=None):
"""Generate 'total' repetitions between 'min_reps' and 'max_reps',
if existing is given (not None), then some repetitions are already
drawn.
Parameters
----------
min_reps
Lower limit for the repetitions dawing, e.g. 3.... | [
"def",
"generate_reps",
"(",
"min_reps",
"=",
"3",
",",
"max_reps",
"=",
"8",
",",
"total",
"=",
"25",
",",
"existing",
"=",
"None",
")",
":",
"# If no existing repetitions exist, start from empty list",
"if",
"existing",
"is",
"None",
":",
"existing",
"=",
"[... | Generate 'total' repetitions between 'min_reps' and 'max_reps',
if existing is given (not None), then some repetitions are already
drawn.
Parameters
----------
min_reps
Lower limit for the repetitions dawing, e.g. 3.
max_reps
Upper limit for the repetitions dawing, e.g.... | [
"Generate",
"total",
"repetitions",
"between",
"min_reps",
"and",
"max_reps",
"if",
"existing",
"is",
"given",
"(",
"not",
"None",
")",
"then",
"some",
"repetitions",
"are",
"already",
"drawn",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L227-L273 |
tommyod/streprogen | streprogen/utils.py | spread | def spread(iterable):
"""Returns the maximal spread of a sorted list of numbers.
Parameters
----------
iterable
A list of numbers.
Returns
-------
max_diff
The maximal difference when the iterable is sorted.
Examples
-------
>>> spread([1, 11, 13, 15])
10
... | python | def spread(iterable):
"""Returns the maximal spread of a sorted list of numbers.
Parameters
----------
iterable
A list of numbers.
Returns
-------
max_diff
The maximal difference when the iterable is sorted.
Examples
-------
>>> spread([1, 11, 13, 15])
10
... | [
"def",
"spread",
"(",
"iterable",
")",
":",
"if",
"len",
"(",
"iterable",
")",
"==",
"1",
":",
"return",
"0",
"iterable",
"=",
"iterable",
".",
"copy",
"(",
")",
"iterable",
".",
"sort",
"(",
")",
"max_diff",
"=",
"max",
"(",
"abs",
"(",
"i",
"-"... | Returns the maximal spread of a sorted list of numbers.
Parameters
----------
iterable
A list of numbers.
Returns
-------
max_diff
The maximal difference when the iterable is sorted.
Examples
-------
>>> spread([1, 11, 13, 15])
10
>>> spread([1, 15, 1... | [
"Returns",
"the",
"maximal",
"spread",
"of",
"a",
"sorted",
"list",
"of",
"numbers",
"."
] | train | https://github.com/tommyod/streprogen/blob/21b903618e8b2d398bceb394d18d7c74ca984def/streprogen/utils.py#L276-L306 |
RyoHina/vc | vc/create.py | create_image_base64 | def create_image_base64():
"""
创建一个验证码 + 图片base64字符串流
"""
code, file = create_image()
b64str = "data:image/png;base64,"
with open(file, "rb") as f:
if sys.version_info.major == 2:
b64str += base64.b64encode(f.read())
else:
b64str += base64.b64encode(f.... | python | def create_image_base64():
"""
创建一个验证码 + 图片base64字符串流
"""
code, file = create_image()
b64str = "data:image/png;base64,"
with open(file, "rb") as f:
if sys.version_info.major == 2:
b64str += base64.b64encode(f.read())
else:
b64str += base64.b64encode(f.... | [
"def",
"create_image_base64",
"(",
")",
":",
"code",
",",
"file",
"=",
"create_image",
"(",
")",
"b64str",
"=",
"\"data:image/png;base64,\"",
"with",
"open",
"(",
"file",
",",
"\"rb\"",
")",
"as",
"f",
":",
"if",
"sys",
".",
"version_info",
".",
"major",
... | 创建一个验证码 + 图片base64字符串流 | [
"创建一个验证码",
"+",
"图片base64字符串流"
] | train | https://github.com/RyoHina/vc/blob/b887bf991794ab4b4876e865eb9ab79936faed49/vc/create.py#L15-L27 |
gridaphobe/pyGravatar | gravatar.py | Gravatar.secure | def secure(self, value):
"""Set the secure parameter and regenerate the thumbnail link."""
self._secure = value
self._thumb = self._link_to_img() | python | def secure(self, value):
"""Set the secure parameter and regenerate the thumbnail link."""
self._secure = value
self._thumb = self._link_to_img() | [
"def",
"secure",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_secure",
"=",
"value",
"self",
".",
"_thumb",
"=",
"self",
".",
"_link_to_img",
"(",
")"
] | Set the secure parameter and regenerate the thumbnail link. | [
"Set",
"the",
"secure",
"parameter",
"and",
"regenerate",
"the",
"thumbnail",
"link",
"."
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L55-L58 |
gridaphobe/pyGravatar | gravatar.py | Gravatar.rating | def rating(self, value):
"""Set the rating parameter and regenerate the thumbnail link."""
self._rating = value
self._thumb = self._link_to_img() | python | def rating(self, value):
"""Set the rating parameter and regenerate the thumbnail link."""
self._rating = value
self._thumb = self._link_to_img() | [
"def",
"rating",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_rating",
"=",
"value",
"self",
".",
"_thumb",
"=",
"self",
".",
"_link_to_img",
"(",
")"
] | Set the rating parameter and regenerate the thumbnail link. | [
"Set",
"the",
"rating",
"parameter",
"and",
"regenerate",
"the",
"thumbnail",
"link",
"."
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L66-L69 |
gridaphobe/pyGravatar | gravatar.py | Gravatar.size | def size(self, value):
"""Set the size parameter and regenerate the thumbnail link."""
self._size = value
self._thumb = self._link_to_img() | python | def size(self, value):
"""Set the size parameter and regenerate the thumbnail link."""
self._size = value
self._thumb = self._link_to_img() | [
"def",
"size",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_size",
"=",
"value",
"self",
".",
"_thumb",
"=",
"self",
".",
"_link_to_img",
"(",
")"
] | Set the size parameter and regenerate the thumbnail link. | [
"Set",
"the",
"size",
"parameter",
"and",
"regenerate",
"the",
"thumbnail",
"link",
"."
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L77-L80 |
gridaphobe/pyGravatar | gravatar.py | Gravatar.default | def default(self, value):
"""Set the default parameter and regenerate the thumbnail link."""
self._default = value
self._thumb = self._link_to_img() | python | def default(self, value):
"""Set the default parameter and regenerate the thumbnail link."""
self._default = value
self._thumb = self._link_to_img() | [
"def",
"default",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_default",
"=",
"value",
"self",
".",
"_thumb",
"=",
"self",
".",
"_link_to_img",
"(",
")"
] | Set the default parameter and regenerate the thumbnail link. | [
"Set",
"the",
"default",
"parameter",
"and",
"regenerate",
"the",
"thumbnail",
"link",
"."
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L88-L91 |
gridaphobe/pyGravatar | gravatar.py | Gravatar._link_to_img | def _link_to_img(self):
"""
Generates a link to the user's Gravatar.
>>> Gravatar('gridaphobe@gmail.com')._link_to_img()
'http://www.gravatar.com/avatar/16b87da510d278999c892cdbdd55c1b6?s=80&r=g'
"""
# make sure options are valid
if self.rating.lower() no... | python | def _link_to_img(self):
"""
Generates a link to the user's Gravatar.
>>> Gravatar('gridaphobe@gmail.com')._link_to_img()
'http://www.gravatar.com/avatar/16b87da510d278999c892cdbdd55c1b6?s=80&r=g'
"""
# make sure options are valid
if self.rating.lower() no... | [
"def",
"_link_to_img",
"(",
"self",
")",
":",
"# make sure options are valid",
"if",
"self",
".",
"rating",
".",
"lower",
"(",
")",
"not",
"in",
"RATINGS",
":",
"raise",
"InvalidRatingError",
"(",
"self",
".",
"rating",
")",
"if",
"not",
"(",
"MIN_SIZE",
"... | Generates a link to the user's Gravatar.
>>> Gravatar('gridaphobe@gmail.com')._link_to_img()
'http://www.gravatar.com/avatar/16b87da510d278999c892cdbdd55c1b6?s=80&r=g' | [
"Generates",
"a",
"link",
"to",
"the",
"user",
"s",
"Gravatar",
".",
">>>",
"Gravatar",
"(",
"gridaphobe"
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L98-L121 |
gridaphobe/pyGravatar | gravatar.py | Gravatar._get_profile | def _get_profile(self):
"""
Retrieves the profile data of the user and formats it as a
Python dictionary.
"""
url = PROFILE_URL + self.hash + '.json'
try:
profile = json.load(urlopen(url))
# set the profile as an instance variable
self.... | python | def _get_profile(self):
"""
Retrieves the profile data of the user and formats it as a
Python dictionary.
"""
url = PROFILE_URL + self.hash + '.json'
try:
profile = json.load(urlopen(url))
# set the profile as an instance variable
self.... | [
"def",
"_get_profile",
"(",
"self",
")",
":",
"url",
"=",
"PROFILE_URL",
"+",
"self",
".",
"hash",
"+",
"'.json'",
"try",
":",
"profile",
"=",
"json",
".",
"load",
"(",
"urlopen",
"(",
"url",
")",
")",
"# set the profile as an instance variable",
"self",
"... | Retrieves the profile data of the user and formats it as a
Python dictionary. | [
"Retrieves",
"the",
"profile",
"data",
"of",
"the",
"user",
"and",
"formats",
"it",
"as",
"a",
"Python",
"dictionary",
"."
] | train | https://github.com/gridaphobe/pyGravatar/blob/6b28984136bd3ddacc11f253af54456892fd17ca/gravatar.py#L123-L134 |
cloudnull/cloudlib | cloudlib/http.py | parse_url | def parse_url(url):
"""Return a clean URL. Remove the prefix for the Auth URL if Found.
:param url:
:return aurl:
"""
if url.startswith(('http', 'https', '//')):
if url.startswith('//'):
return urlparse.urlparse(url, scheme='http')
else:
return urlparse.urlpa... | python | def parse_url(url):
"""Return a clean URL. Remove the prefix for the Auth URL if Found.
:param url:
:return aurl:
"""
if url.startswith(('http', 'https', '//')):
if url.startswith('//'):
return urlparse.urlparse(url, scheme='http')
else:
return urlparse.urlpa... | [
"def",
"parse_url",
"(",
"url",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"(",
"'http'",
",",
"'https'",
",",
"'//'",
")",
")",
":",
"if",
"url",
".",
"startswith",
"(",
"'//'",
")",
":",
"return",
"urlparse",
".",
"urlparse",
"(",
"url",
",",... | Return a clean URL. Remove the prefix for the Auth URL if Found.
:param url:
:return aurl: | [
"Return",
"a",
"clean",
"URL",
".",
"Remove",
"the",
"prefix",
"for",
"the",
"Auth",
"URL",
"if",
"Found",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L43-L55 |
cloudnull/cloudlib | cloudlib/http.py | html_encode | def html_encode(path):
"""Return an HTML encoded Path.
:param path: ``str``
:return: ``str``
"""
if sys.version_info > (3, 2, 0):
return urllib.parse.quote(utils.ensure_string(path))
else:
return urllib.quote(utils.ensure_string(path)) | python | def html_encode(path):
"""Return an HTML encoded Path.
:param path: ``str``
:return: ``str``
"""
if sys.version_info > (3, 2, 0):
return urllib.parse.quote(utils.ensure_string(path))
else:
return urllib.quote(utils.ensure_string(path)) | [
"def",
"html_encode",
"(",
"path",
")",
":",
"if",
"sys",
".",
"version_info",
">",
"(",
"3",
",",
"2",
",",
"0",
")",
":",
"return",
"urllib",
".",
"parse",
".",
"quote",
"(",
"utils",
".",
"ensure_string",
"(",
"path",
")",
")",
"else",
":",
"r... | Return an HTML encoded Path.
:param path: ``str``
:return: ``str`` | [
"Return",
"an",
"HTML",
"encoded",
"Path",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L58-L67 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest._get_url | def _get_url(url):
"""Returns a URL string.
If the ``url`` parameter is a ParsedResult from `urlparse` the full url
will be unparsed and made into a string. Otherwise the ``url``
parameter is returned as is.
:param url: ``str`` || ``object``
"""
if isinstance(ur... | python | def _get_url(url):
"""Returns a URL string.
If the ``url`` parameter is a ParsedResult from `urlparse` the full url
will be unparsed and made into a string. Otherwise the ``url``
parameter is returned as is.
:param url: ``str`` || ``object``
"""
if isinstance(ur... | [
"def",
"_get_url",
"(",
"url",
")",
":",
"if",
"isinstance",
"(",
"url",
",",
"urlparse",
".",
"ParseResult",
")",
":",
"return",
"urlparse",
".",
"urlunparse",
"(",
"url",
")",
"else",
":",
"return",
"url"
] | Returns a URL string.
If the ``url`` parameter is a ParsedResult from `urlparse` the full url
will be unparsed and made into a string. Otherwise the ``url``
parameter is returned as is.
:param url: ``str`` || ``object`` | [
"Returns",
"a",
"URL",
"string",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L104-L116 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest._report_error | def _report_error(self, request, exp):
"""When making the request, if an error happens, log it."""
message = (
"Failure to perform %s due to [ %s ]" % (request, exp)
)
self.log.fatal(message)
raise requests.RequestException(message) | python | def _report_error(self, request, exp):
"""When making the request, if an error happens, log it."""
message = (
"Failure to perform %s due to [ %s ]" % (request, exp)
)
self.log.fatal(message)
raise requests.RequestException(message) | [
"def",
"_report_error",
"(",
"self",
",",
"request",
",",
"exp",
")",
":",
"message",
"=",
"(",
"\"Failure to perform %s due to [ %s ]\"",
"%",
"(",
"request",
",",
"exp",
")",
")",
"self",
".",
"log",
".",
"fatal",
"(",
"message",
")",
"raise",
"requests"... | When making the request, if an error happens, log it. | [
"When",
"making",
"the",
"request",
"if",
"an",
"error",
"happens",
"log",
"it",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L118-L124 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest._request | def _request(self, method, url, headers=None, body=None, kwargs=None):
"""Make a request.
To make a request pass the ``method`` and the ``url``. Valid methods
are, ``['post', 'put', 'get', 'delete', 'patch', 'option', 'head']``.
:param url: ``str``
:param headers: ``dict``
... | python | def _request(self, method, url, headers=None, body=None, kwargs=None):
"""Make a request.
To make a request pass the ``method`` and the ``url``. Valid methods
are, ``['post', 'put', 'get', 'delete', 'patch', 'option', 'head']``.
:param url: ``str``
:param headers: ``dict``
... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"url",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"_kwargs",
"=",
"utils",
".",
"dict_update",
"(",
"self",
".",
"request_kwargs",
".",
"copy",
"(",... | Make a request.
To make a request pass the ``method`` and the ``url``. Valid methods
are, ``['post', 'put', 'get', 'delete', 'patch', 'option', 'head']``.
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict`` | [
"Make",
"a",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L126-L153 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.post | def post(self, url, headers=None, body=None, kwargs=None):
"""Make a POST request.
To make a POST request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
met... | python | def post(self, url, headers=None, body=None, kwargs=None):
"""Make a POST request.
To make a POST request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
met... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'post'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"he... | Make a POST request.
To make a POST request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict`` | [
"Make",
"a",
"POST",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L155-L171 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.head | def head(self, url, headers=None, kwargs=None):
"""Make a HEAD request.
To make a HEAD request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='head',
url=url,
... | python | def head(self, url, headers=None, kwargs=None):
"""Make a HEAD request.
To make a HEAD request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='head',
url=url,
... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'head'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"headers",
",",
"kwargs",
"=",
... | Make a HEAD request.
To make a HEAD request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict`` | [
"Make",
"a",
"HEAD",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L173-L187 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.patch | def patch(self, url, headers=None, body=None, kwargs=None):
"""Make a PATCH request.
To make a PATCH request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
... | python | def patch(self, url, headers=None, body=None, kwargs=None):
"""Make a PATCH request.
To make a PATCH request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'patch'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"... | Make a PATCH request.
To make a PATCH request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict`` | [
"Make",
"a",
"PATCH",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L189-L205 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.put | def put(self, url, headers=None, body=None, kwargs=None):
"""Make a PUT request.
To make a PUT request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
method... | python | def put(self, url, headers=None, body=None, kwargs=None):
"""Make a PUT request.
To make a PUT request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict``
"""
return self._request(
method... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"body",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'put'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"head... | Make a PUT request.
To make a PUT request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param body: ``object``
:param kwargs: ``dict`` | [
"Make",
"a",
"PUT",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L207-L223 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.delete | def delete(self, url, headers=None, kwargs=None):
"""Make a DELETE request.
To make a DELETE request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='delete',
url=url,
... | python | def delete(self, url, headers=None, kwargs=None):
"""Make a DELETE request.
To make a DELETE request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='delete',
url=url,
... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'delete'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"headers",
",",
"kwargs",
"... | Make a DELETE request.
To make a DELETE request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict`` | [
"Make",
"a",
"DELETE",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L225-L239 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.get | def get(self, url, headers=None, kwargs=None):
"""Make a GET request.
To make a GET request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='get',
url=url,
he... | python | def get(self, url, headers=None, kwargs=None):
"""Make a GET request.
To make a GET request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='get',
url=url,
he... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'get'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"headers",
",",
"kwargs",
"=",
... | Make a GET request.
To make a GET request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict`` | [
"Make",
"a",
"GET",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L241-L255 |
cloudnull/cloudlib | cloudlib/http.py | MakeRequest.option | def option(self, url, headers=None, kwargs=None):
"""Make a OPTION request.
To make a OPTION request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='option',
url=url,
... | python | def option(self, url, headers=None, kwargs=None):
"""Make a OPTION request.
To make a OPTION request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict``
"""
return self._request(
method='option',
url=url,
... | [
"def",
"option",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"return",
"self",
".",
"_request",
"(",
"method",
"=",
"'option'",
",",
"url",
"=",
"url",
",",
"headers",
"=",
"headers",
",",
"kwargs",
"... | Make a OPTION request.
To make a OPTION request pass, ``url``
:param url: ``str``
:param headers: ``dict``
:param kwargs: ``dict`` | [
"Make",
"a",
"OPTION",
"request",
"."
] | train | https://github.com/cloudnull/cloudlib/blob/5038111ce02521caa2558117e3bae9e1e806d315/cloudlib/http.py#L257-L271 |
ivbeg/qddate | qddate/qdparser.py | DateParser.__generate | def __generate(self):
"""Generates dates patterns"""
base = []
texted = []
for pat in ALL_PATTERNS:
data = pat.copy()
data['pattern'] = data['pattern']
data['right'] = True
data['basekey'] = data['key']
base.append(data)
... | python | def __generate(self):
"""Generates dates patterns"""
base = []
texted = []
for pat in ALL_PATTERNS:
data = pat.copy()
data['pattern'] = data['pattern']
data['right'] = True
data['basekey'] = data['key']
base.append(data)
... | [
"def",
"__generate",
"(",
"self",
")",
":",
"base",
"=",
"[",
"]",
"texted",
"=",
"[",
"]",
"for",
"pat",
"in",
"ALL_PATTERNS",
":",
"data",
"=",
"pat",
".",
"copy",
"(",
")",
"data",
"[",
"'pattern'",
"]",
"=",
"data",
"[",
"'pattern'",
"]",
"da... | Generates dates patterns | [
"Generates",
"dates",
"patterns"
] | train | https://github.com/ivbeg/qddate/blob/f7730610611f2509ab264bc8d77a902742daf08c/qddate/qdparser.py#L39-L77 |
ivbeg/qddate | qddate/qdparser.py | DateParser.match | def match(self, text, noprefix=False):
"""Matches date/datetime string against date patterns and returns pattern and parsed date if matched.
It's not indeded for common usage, since if successful it returns date as array of numbers and pattern
that matched this date
:param text:
... | python | def match(self, text, noprefix=False):
"""Matches date/datetime string against date patterns and returns pattern and parsed date if matched.
It's not indeded for common usage, since if successful it returns date as array of numbers and pattern
that matched this date
:param text:
... | [
"def",
"match",
"(",
"self",
",",
"text",
",",
"noprefix",
"=",
"False",
")",
":",
"n",
"=",
"len",
"(",
"text",
")",
"if",
"self",
".",
"cachedpats",
"is",
"not",
"None",
":",
"pats",
"=",
"self",
".",
"cachedpats",
"else",
":",
"pats",
"=",
"se... | Matches date/datetime string against date patterns and returns pattern and parsed date if matched.
It's not indeded for common usage, since if successful it returns date as array of numbers and pattern
that matched this date
:param text:
Any human readable string
:type date_... | [
"Matches",
"date",
"/",
"datetime",
"string",
"against",
"date",
"patterns",
"and",
"returns",
"pattern",
"and",
"parsed",
"date",
"if",
"matched",
".",
"It",
"s",
"not",
"indeded",
"for",
"common",
"usage",
"since",
"if",
"successful",
"it",
"returns",
"dat... | train | https://github.com/ivbeg/qddate/blob/f7730610611f2509ab264bc8d77a902742daf08c/qddate/qdparser.py#L79-L122 |
ivbeg/qddate | qddate/qdparser.py | DateParser.parse | def parse(self, text, noprefix=False):
"""Parse date and time from given date string.
:param text:
Any human readable string
:type date_string: str|unicode
:param noprefix:
If set True than doesn't use prefix based date patterns filtering settings
:type n... | python | def parse(self, text, noprefix=False):
"""Parse date and time from given date string.
:param text:
Any human readable string
:type date_string: str|unicode
:param noprefix:
If set True than doesn't use prefix based date patterns filtering settings
:type n... | [
"def",
"parse",
"(",
"self",
",",
"text",
",",
"noprefix",
"=",
"False",
")",
":",
"res",
"=",
"self",
".",
"match",
"(",
"text",
",",
"noprefix",
")",
"if",
"res",
":",
"r",
"=",
"res",
"[",
"'values'",
"]",
"p",
"=",
"res",
"[",
"'pattern'",
... | Parse date and time from given date string.
:param text:
Any human readable string
:type date_string: str|unicode
:param noprefix:
If set True than doesn't use prefix based date patterns filtering settings
:type noprefix: bool
:return: Returns :class:`d... | [
"Parse",
"date",
"and",
"time",
"from",
"given",
"date",
"string",
"."
] | train | https://github.com/ivbeg/qddate/blob/f7730610611f2509ab264bc8d77a902742daf08c/qddate/qdparser.py#L124-L149 |
chop-dbhi/varify | varify/migrations/0002_avocado_metadata_migration.py | Migration.forwards | def forwards(self, orm):
"Perform a 'safe' load using Avocado's backup utilities."
from avocado.core import backup
backup.safe_load(u'0002_avocado_metadata', backup_path=None,
using='default') | python | def forwards(self, orm):
"Perform a 'safe' load using Avocado's backup utilities."
from avocado.core import backup
backup.safe_load(u'0002_avocado_metadata', backup_path=None,
using='default') | [
"def",
"forwards",
"(",
"self",
",",
"orm",
")",
":",
"from",
"avocado",
".",
"core",
"import",
"backup",
"backup",
".",
"safe_load",
"(",
"u'0002_avocado_metadata'",
",",
"backup_path",
"=",
"None",
",",
"using",
"=",
"'default'",
")"
] | Perform a 'safe' load using Avocado's backup utilities. | [
"Perform",
"a",
"safe",
"load",
"using",
"Avocado",
"s",
"backup",
"utilities",
"."
] | train | https://github.com/chop-dbhi/varify/blob/5dc721e49ed9bd3582f4b117785fdd1a8b6ba777/varify/migrations/0002_avocado_metadata_migration.py#L10-L14 |
mitsei/dlkit | dlkit/handcar/id/objects.py | IdList.get_next_id | def get_next_id(self):
"""Gets the next Id in this list.
return: (osid.id.Id) - the next Id in this list. The has_next()
method should be used to test that a next Id is
available before calling this method.
raise: IllegalState - no more elements available in thi... | python | def get_next_id(self):
"""Gets the next Id in this list.
return: (osid.id.Id) - the next Id in this list. The has_next()
method should be used to test that a next Id is
available before calling this method.
raise: IllegalState - no more elements available in thi... | [
"def",
"get_next_id",
"(",
"self",
")",
":",
"try",
":",
"next_item",
"=",
"next",
"(",
"self",
")",
"except",
"StopIteration",
":",
"raise",
"IllegalState",
"(",
"'no more elements available in this list'",
")",
"except",
"Exception",
":",
"# Need to specify except... | Gets the next Id in this list.
return: (osid.id.Id) - the next Id in this list. The has_next()
method should be used to test that a next Id is
available before calling this method.
raise: IllegalState - no more elements available in this list
raise: OperationFa... | [
"Gets",
"the",
"next",
"Id",
"in",
"this",
"list",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/handcar/id/objects.py#L29-L47 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogQuerySession.get_catalogs_by_query | def get_catalogs_by_query(self, catalog_query):
"""Gets a list of ``Catalogs`` matching the given catalog query.
arg: catalog_query (osid.cataloging.CatalogQuery): the
catalog query
return: (osid.cataloging.CatalogList) - the returned
``CatalogList``
r... | python | def get_catalogs_by_query(self, catalog_query):
"""Gets a list of ``Catalogs`` matching the given catalog query.
arg: catalog_query (osid.cataloging.CatalogQuery): the
catalog query
return: (osid.cataloging.CatalogList) - the returned
``CatalogList``
r... | [
"def",
"get_catalogs_by_query",
"(",
"self",
",",
"catalog_query",
")",
":",
"# Implemented from template for",
"# osid.resource.BinQuerySession.get_bins_by_query_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_se... | Gets a list of ``Catalogs`` matching the given catalog query.
arg: catalog_query (osid.cataloging.CatalogQuery): the
catalog query
return: (osid.cataloging.CatalogList) - the returned
``CatalogList``
raise: NullArgument - ``catalog_query`` is ``null``
... | [
"Gets",
"a",
"list",
"of",
"Catalogs",
"matching",
"the",
"given",
"catalog",
"query",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L379-L403 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogAdminSession.can_create_catalog_with_record_types | def can_create_catalog_with_record_types(self, catalog_record_types):
"""Tests if this user can create a single ``Catalog`` using the desired record types.
While ``CatalogingManager.getCatalogRecordTypes()`` can be used
to examine which records are supported, this method tests which
rec... | python | def can_create_catalog_with_record_types(self, catalog_record_types):
"""Tests if this user can create a single ``Catalog`` using the desired record types.
While ``CatalogingManager.getCatalogRecordTypes()`` can be used
to examine which records are supported, this method tests which
rec... | [
"def",
"can_create_catalog_with_record_types",
"(",
"self",
",",
"catalog_record_types",
")",
":",
"# Implemented from template for",
"# osid.resource.BinAdminSession.can_create_bin_with_record_types",
"# NOTE: It is expected that real authentication hints will be",
"# handled in a service ada... | Tests if this user can create a single ``Catalog`` using the desired record types.
While ``CatalogingManager.getCatalogRecordTypes()`` can be used
to examine which records are supported, this method tests which
record(s) are required for creating a specific ``Catalog``.
Providing an emp... | [
"Tests",
"if",
"this",
"user",
"can",
"create",
"a",
"single",
"Catalog",
"using",
"the",
"desired",
"record",
"types",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L470-L494 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogAdminSession.update_catalog | def update_catalog(self, catalog_form):
"""Updates an existing catalog.
arg: catalog_form (osid.cataloging.CatalogForm): the form
containing the elements to be updated
raise: IllegalState - ``catalog_form`` already used in an
update transaction
raise:... | python | def update_catalog(self, catalog_form):
"""Updates an existing catalog.
arg: catalog_form (osid.cataloging.CatalogForm): the form
containing the elements to be updated
raise: IllegalState - ``catalog_form`` already used in an
update transaction
raise:... | [
"def",
"update_catalog",
"(",
"self",
",",
"catalog_form",
")",
":",
"# Implemented from template for",
"# osid.resource.BinAdminSession.update_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",
... | Updates an existing catalog.
arg: catalog_form (osid.cataloging.CatalogForm): the form
containing the elements to be updated
raise: IllegalState - ``catalog_form`` already used in an
update transaction
raise: InvalidArgument - the form contains an invalid va... | [
"Updates",
"an",
"existing",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L636-L675 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogAdminSession.delete_catalog | def delete_catalog(self, catalog_id):
"""Deletes a ``Catalog``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to remove
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable... | python | def delete_catalog(self, catalog_id):
"""Deletes a ``Catalog``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to remove
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable... | [
"def",
"delete_catalog",
"(",
"self",
",",
"catalog_id",
")",
":",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",
"delete_catalog",
"(",
"catalog_id",
"=",
"bin_id",
")",
"collection",
"=",
"J... | Deletes a ``Catalog``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to remove
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete request
raise: PermissionDe... | [
"Deletes",
"a",
"Catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L700-L719 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogAdminSession.alias_catalog | def alias_catalog(self, catalog_id, alias_id):
"""Adds an ``Id`` to a ``Catalog`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Catalog`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to anoth... | python | def alias_catalog(self, catalog_id, alias_id):
"""Adds an ``Id`` to a ``Catalog`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Catalog`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to anoth... | [
"def",
"alias_catalog",
"(",
"self",
",",
"catalog_id",
",",
"alias_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinLookupSession.alias_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog... | Adds an ``Id`` to a ``Catalog`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Catalog`` is determined by the
provider. The new ``Id`` performs as an alias to the primary
``Id``. If the alias is a pointer to another catalog, it is
reassigned to the given catalog ... | [
"Adds",
"an",
"Id",
"to",
"a",
"Catalog",
"for",
"the",
"purpose",
"of",
"creating",
"compatibility",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L740-L763 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_root_catalogs | def get_root_catalogs(self):
"""Gets the root catalogs in the catalog hierarchy.
A node with no parents is an orphan. While all catalog ``Ids``
are known to the hierarchy, an orphan does not appear in the
hierarchy unless explicitly added as a root node or child of
another node.... | python | def get_root_catalogs(self):
"""Gets the root catalogs in the catalog hierarchy.
A node with no parents is an orphan. While all catalog ``Ids``
are known to the hierarchy, an orphan does not appear in the
hierarchy unless explicitly added as a root node or child of
another node.... | [
"def",
"get_root_catalogs",
"(",
"self",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_root_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",
"get_root_catalogs",
... | Gets the root catalogs in the catalog hierarchy.
A node with no parents is an orphan. While all catalog ``Ids``
are known to the hierarchy, an orphan does not appear in the
hierarchy unless explicitly added as a root node or child of
another node.
return: (osid.cataloging.Catal... | [
"Gets",
"the",
"root",
"catalogs",
"in",
"the",
"catalog",
"hierarchy",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L915-L935 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.has_parent_catalogs | def has_parent_catalogs(self, catalog_id):
"""Tests if the ``Catalog`` has any parents.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (boolean) - ``true`` if the catalog has parents,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
r... | python | def has_parent_catalogs(self, catalog_id):
"""Tests if the ``Catalog`` has any parents.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (boolean) - ``true`` if the catalog has parents,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
r... | [
"def",
"has_parent_catalogs",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.has_parent_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".... | Tests if the ``Catalog`` has any parents.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (boolean) - ``true`` if the catalog has parents,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalog_id`` is ``null``
... | [
"Tests",
"if",
"the",
"Catalog",
"has",
"any",
"parents",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L940-L957 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.is_parent_of_catalog | def is_parent_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is a direct parent of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is a parent of
``catalog_id,`` ... | python | def is_parent_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is a direct parent of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is a parent of
``catalog_id,`` ... | [
"def",
"is_parent_of_catalog",
"(",
"self",
",",
"id_",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.is_parent_of_bin",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_cata... | Tests if an ``Id`` is a direct parent of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is a parent of
``catalog_id,`` ``false`` otherwise
raise: NotFound - ``catalog_id... | [
"Tests",
"if",
"an",
"Id",
"is",
"a",
"direct",
"parent",
"of",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L960-L979 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_parent_catalog_ids | def get_parent_catalog_ids(self, catalog_id):
"""Gets the parent ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (osid.id.IdList) - the parent ``Ids`` of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``c... | python | def get_parent_catalog_ids(self, catalog_id):
"""Gets the parent ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (osid.id.IdList) - the parent ``Ids`` of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``c... | [
"def",
"get_parent_catalog_ids",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_parent_bin_ids",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session"... | Gets the parent ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): a catalog ``Id``
return: (osid.id.IdList) - the parent ``Ids`` of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed -... | [
"Gets",
"the",
"parent",
"Ids",
"of",
"the",
"given",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L982-L998 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_parent_catalogs | def get_parent_catalogs(self, catalog_id):
"""Gets the parent catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the parent catalogs of
the ``id``
raise: NotFound ... | python | def get_parent_catalogs(self, catalog_id):
"""Gets the parent catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the parent catalogs of
the ``id``
raise: NotFound ... | [
"def",
"get_parent_catalogs",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_parent_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".... | Gets the parent catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the parent catalogs of
the ``id``
raise: NotFound - a ``Catalog`` identified by ``Id is`` not
... | [
"Gets",
"the",
"parent",
"catalogs",
"of",
"the",
"given",
"id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1001-L1023 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.is_ancestor_of_catalog | def is_ancestor_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is an ancestor of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is an ancestor of
``catalogId``. ... | python | def is_ancestor_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is an ancestor of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is an ancestor of
``catalogId``. ... | [
"def",
"is_ancestor_of_catalog",
"(",
"self",
",",
"id_",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.is_ancestor_of_bin",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_... | Tests if an ``Id`` is an ancestor of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if this ``id`` is an ancestor of
``catalogId``. ``false`` otherwise
raise: NotFound - ``catalog_id``... | [
"Tests",
"if",
"an",
"Id",
"is",
"an",
"ancestor",
"of",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1026-L1045 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.has_child_catalogs | def has_child_catalogs(self, catalog_id):
"""Tests if a catalog has any children.
arg: catalog_id (osid.id.Id): a ``catalog_id``
return: (boolean) - ``true`` if the ``catalog_id`` has children,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
... | python | def has_child_catalogs(self, catalog_id):
"""Tests if a catalog has any children.
arg: catalog_id (osid.id.Id): a ``catalog_id``
return: (boolean) - ``true`` if the ``catalog_id`` has children,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
... | [
"def",
"has_child_catalogs",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.has_child_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",... | Tests if a catalog has any children.
arg: catalog_id (osid.id.Id): a ``catalog_id``
return: (boolean) - ``true`` if the ``catalog_id`` has children,
``false`` otherwise
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalog_id`` is ``null``
... | [
"Tests",
"if",
"a",
"catalog",
"has",
"any",
"children",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1048-L1065 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.is_child_of_catalog | def is_child_of_catalog(self, id_, catalog_id):
"""Tests if a catalog is a direct child of another.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a child of
``catalog_id,`` ``fal... | python | def is_child_of_catalog(self, id_, catalog_id):
"""Tests if a catalog is a direct child of another.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a child of
``catalog_id,`` ``fal... | [
"def",
"is_child_of_catalog",
"(",
"self",
",",
"id_",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.is_child_of_bin",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalo... | Tests if a catalog is a direct child of another.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a child of
``catalog_id,`` ``false`` otherwise
raise: NotFound - ``catalog_id`` no... | [
"Tests",
"if",
"a",
"catalog",
"is",
"a",
"direct",
"child",
"of",
"another",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1068-L1087 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_child_catalog_ids | def get_child_catalog_ids(self, catalog_id):
"""Gets the child ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalo... | python | def get_child_catalog_ids(self, catalog_id):
"""Gets the child ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalo... | [
"def",
"get_child_catalog_ids",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bin_ids",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
... | Gets the child ``Ids`` of the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
return: (osid.id.IdList) - the children of the catalog
raise: NotFound - ``catalog_id`` is not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - una... | [
"Gets",
"the",
"child",
"Ids",
"of",
"the",
"given",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1090-L1106 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_child_catalogs | def get_child_catalogs(self, catalog_id):
"""Gets the child catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the child catalogs of
the ``id``
raise: NotFound - a... | python | def get_child_catalogs(self, catalog_id):
"""Gets the child catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the child catalogs of
the ``id``
raise: NotFound - a... | [
"def",
"get_child_catalogs",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_child_bins",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_session",
".",... | Gets the child catalogs of the given ``id``.
arg: catalog_id (osid.id.Id): the ``Id`` of the ``Catalog``
to query
return: (osid.cataloging.CatalogList) - the child catalogs of
the ``id``
raise: NotFound - a ``Catalog`` identified by ``Id is`` not
... | [
"Gets",
"the",
"child",
"catalogs",
"of",
"the",
"given",
"id",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1109-L1131 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.is_descendant_of_catalog | def is_descendant_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is a descendant of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a descendant of
the ``catalo... | python | def is_descendant_of_catalog(self, id_, catalog_id):
"""Tests if an ``Id`` is a descendant of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a descendant of
the ``catalo... | [
"def",
"is_descendant_of_catalog",
"(",
"self",
",",
"id_",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.is_descendant_of_bin",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
... | Tests if an ``Id`` is a descendant of a catalog.
arg: id (osid.id.Id): an ``Id``
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
return: (boolean) - ``true`` if the ``id`` is a descendant of
the ``catalog_id,`` ``false`` otherwise
raise: NotFound - ``catalo... | [
"Tests",
"if",
"an",
"Id",
"is",
"a",
"descendant",
"of",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1134-L1153 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchySession.get_catalog_nodes | def get_catalog_nodes(self, catalog_id, ancestor_levels, descendant_levels, include_siblings):
"""Gets a portion of the hierarchy for the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
arg: ancestor_levels (cardinal): the maximum number of
ancestor levels... | python | def get_catalog_nodes(self, catalog_id, ancestor_levels, descendant_levels, include_siblings):
"""Gets a portion of the hierarchy for the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
arg: ancestor_levels (cardinal): the maximum number of
ancestor levels... | [
"def",
"get_catalog_nodes",
"(",
"self",
",",
"catalog_id",
",",
"ancestor_levels",
",",
"descendant_levels",
",",
"include_siblings",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchySession.get_bin_nodes",
"return",
"objects",
".",
"CatalogNode",
"(... | Gets a portion of the hierarchy for the given catalog.
arg: catalog_id (osid.id.Id): the ``Id`` to query
arg: ancestor_levels (cardinal): the maximum number of
ancestor levels to include. A value of 0 returns no
parents in the node.
arg: descendant_level... | [
"Gets",
"a",
"portion",
"of",
"the",
"hierarchy",
"for",
"the",
"given",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1193-L1221 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchyDesignSession.add_root_catalog | def add_root_catalog(self, catalog_id):
"""Adds a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: AlreadyExists - ``catalog_id`` is already in hierarchy
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
... | python | def add_root_catalog(self, catalog_id):
"""Adds a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: AlreadyExists - ``catalog_id`` is already in hierarchy
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
... | [
"def",
"add_root_catalog",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.add_root_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog_sessi... | Adds a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: AlreadyExists - ``catalog_id`` is already in hierarchy
raise: NotFound - ``catalog_id`` not found
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete... | [
"Adds",
"a",
"root",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1309-L1325 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchyDesignSession.remove_root_catalog | def remove_root_catalog(self, catalog_id):
"""Removes a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not a root
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete request
... | python | def remove_root_catalog(self, catalog_id):
"""Removes a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not a root
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete request
... | [
"def",
"remove_root_catalog",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.remove_root_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_catalog... | Removes a root catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not a root
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete request
raise: PermissionDenied - authorization failur... | [
"Removes",
"a",
"root",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1328-L1343 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchyDesignSession.add_child_catalog | def add_child_catalog(self, catalog_id, child_id):
"""Adds a child to a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: AlreadyExists - ``catalog_id`` is already a parent of
``child_id``... | python | def add_child_catalog(self, catalog_id, child_id):
"""Adds a child to a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: AlreadyExists - ``catalog_id`` is already a parent of
``child_id``... | [
"def",
"add_child_catalog",
"(",
"self",
",",
"catalog_id",
",",
"child_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.add_child_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
... | Adds a child to a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: AlreadyExists - ``catalog_id`` is already a parent of
``child_id``
raise: NotFound - ``catalog_id`` or ``child_id`` not... | [
"Adds",
"a",
"child",
"to",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1346-L1365 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchyDesignSession.remove_child_catalog | def remove_child_catalog(self, catalog_id, child_id):
"""Removes a child from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``catalog_id`` is not a parent of
``child_id``
... | python | def remove_child_catalog(self, catalog_id, child_id):
"""Removes a child from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``catalog_id`` is not a parent of
``child_id``
... | [
"def",
"remove_child_catalog",
"(",
"self",
",",
"catalog_id",
",",
"child_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.remove_child_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"se... | Removes a child from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
arg: child_id (osid.id.Id): the ``Id`` of the new child
raise: NotFound - ``catalog_id`` is not a parent of
``child_id``
raise: NullArgument - ``catalog_id`` or ``child_id`` is
... | [
"Removes",
"a",
"child",
"from",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1368-L1386 |
mitsei/dlkit | dlkit/json_/cataloging/sessions.py | CatalogHierarchyDesignSession.remove_child_catalogs | def remove_child_catalogs(self, catalog_id):
"""Removes all children from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not in hierarchy
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable ... | python | def remove_child_catalogs(self, catalog_id):
"""Removes all children from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not in hierarchy
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable ... | [
"def",
"remove_child_catalogs",
"(",
"self",
",",
"catalog_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinHierarchyDesignSession.remove_child_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_cata... | Removes all children from a catalog.
arg: catalog_id (osid.id.Id): the ``Id`` of a catalog
raise: NotFound - ``catalog_id`` is not in hierarchy
raise: NullArgument - ``catalog_id`` is ``null``
raise: OperationFailed - unable to complete request
raise: PermissionDenied - a... | [
"Removes",
"all",
"children",
"from",
"a",
"catalog",
"."
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/cataloging/sessions.py#L1389-L1404 |
SiLab-Bonn/pyBAR_fei4_interpreter | pybar_fei4_interpreter/data_struct.py | generate_scan_parameter_description | def generate_scan_parameter_description(scan_parameters):
'''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (strings)... | python | def generate_scan_parameter_description(scan_parameters):
'''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (strings)... | [
"def",
"generate_scan_parameter_description",
"(",
"scan_parameters",
")",
":",
"table_description",
"=",
"np",
".",
"dtype",
"(",
"[",
"(",
"key",
",",
"tb",
".",
"Int32Col",
"(",
"pos",
"=",
"idx",
")",
")",
"for",
"idx",
",",
"key",
"in",
"enumerate",
... | Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (strings).
Returns
-------
table_description : dict
T... | [
"Generate",
"scan",
"parameter",
"dictionary",
".",
"This",
"is",
"the",
"only",
"way",
"to",
"dynamically",
"create",
"table",
"with",
"dictionary",
"cannot",
"be",
"done",
"with",
"tables",
".",
"IsDescription"
] | train | https://github.com/SiLab-Bonn/pyBAR_fei4_interpreter/blob/0f8df18557598d6db0c64baa708e587c84bb787b/pybar_fei4_interpreter/data_struct.py#L27-L45 |
SiLab-Bonn/pyBAR_fei4_interpreter | pybar_fei4_interpreter/data_struct.py | generate_scan_configuration_description | def generate_scan_configuration_description(scan_parameters):
'''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (stri... | python | def generate_scan_configuration_description(scan_parameters):
'''Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (stri... | [
"def",
"generate_scan_configuration_description",
"(",
"scan_parameters",
")",
":",
"table_description",
"=",
"np",
".",
"dtype",
"(",
"[",
"(",
"key",
",",
"tb",
".",
"StringCol",
"(",
"512",
",",
"pos",
"=",
"idx",
")",
")",
"for",
"idx",
",",
"key",
"... | Generate scan parameter dictionary. This is the only way to dynamically create table with dictionary, cannot be done with tables.IsDescription
Parameters
----------
scan_parameters : list, tuple
List of scan parameters names (strings).
Returns
-------
table_description : dict
T... | [
"Generate",
"scan",
"parameter",
"dictionary",
".",
"This",
"is",
"the",
"only",
"way",
"to",
"dynamically",
"create",
"table",
"with",
"dictionary",
"cannot",
"be",
"done",
"with",
"tables",
".",
"IsDescription"
] | train | https://github.com/SiLab-Bonn/pyBAR_fei4_interpreter/blob/0f8df18557598d6db0c64baa708e587c84bb787b/pybar_fei4_interpreter/data_struct.py#L48-L66 |
ayust/kitnirc | kitnirc/user.py | split_hostmask | def split_hostmask(hostmask):
"""Splits a nick@host string into nick and host."""
nick, _, host = hostmask.partition('@')
nick, _, user = nick.partition('!')
return nick, user or None, host or None | python | def split_hostmask(hostmask):
"""Splits a nick@host string into nick and host."""
nick, _, host = hostmask.partition('@')
nick, _, user = nick.partition('!')
return nick, user or None, host or None | [
"def",
"split_hostmask",
"(",
"hostmask",
")",
":",
"nick",
",",
"_",
",",
"host",
"=",
"hostmask",
".",
"partition",
"(",
"'@'",
")",
"nick",
",",
"_",
",",
"user",
"=",
"nick",
".",
"partition",
"(",
"'!'",
")",
"return",
"nick",
",",
"user",
"or... | Splits a nick@host string into nick and host. | [
"Splits",
"a",
"nick"
] | train | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/user.py#L1-L5 |
raamana/hiwenet | hiwenet/utils.py | compute_histogram | def compute_histogram(values, edges, use_orig_distr=False):
"""Computes histogram (density) for a given vector of values."""
if use_orig_distr:
return values
# ignoring invalid values: Inf and Nan
values = check_array(values).compressed()
hist, bin_edges = np.histogram(values, bins=edges,... | python | def compute_histogram(values, edges, use_orig_distr=False):
"""Computes histogram (density) for a given vector of values."""
if use_orig_distr:
return values
# ignoring invalid values: Inf and Nan
values = check_array(values).compressed()
hist, bin_edges = np.histogram(values, bins=edges,... | [
"def",
"compute_histogram",
"(",
"values",
",",
"edges",
",",
"use_orig_distr",
"=",
"False",
")",
":",
"if",
"use_orig_distr",
":",
"return",
"values",
"# ignoring invalid values: Inf and Nan",
"values",
"=",
"check_array",
"(",
"values",
")",
".",
"compressed",
... | Computes histogram (density) for a given vector of values. | [
"Computes",
"histogram",
"(",
"density",
")",
"for",
"a",
"given",
"vector",
"of",
"values",
"."
] | train | https://github.com/raamana/hiwenet/blob/b12699b3722fd0a6a835e7d7ca4baf58fb181809/hiwenet/utils.py#L10-L22 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.