repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
phaethon/kamene | kamene/pton_ntop.py | inet_ntop | def inet_ntop(af, addr):
"""Convert an IP address from binary form into text represenation"""
if af == socket.AF_INET:
return inet_ntoa(addr)
elif af == socket.AF_INET6:
# IPv6 addresses have 128bits (16 bytes)
if len(addr) != 16:
raise Exception("Illegal syntax for IP ad... | python | def inet_ntop(af, addr):
"""Convert an IP address from binary form into text represenation"""
if af == socket.AF_INET:
return inet_ntoa(addr)
elif af == socket.AF_INET6:
# IPv6 addresses have 128bits (16 bytes)
if len(addr) != 16:
raise Exception("Illegal syntax for IP ad... | [
"def",
"inet_ntop",
"(",
"af",
",",
"addr",
")",
":",
"if",
"af",
"==",
"socket",
".",
"AF_INET",
":",
"return",
"inet_ntoa",
"(",
"addr",
")",
"elif",
"af",
"==",
"socket",
".",
"AF_INET6",
":",
"if",
"len",
"(",
"addr",
")",
"!=",
"16",
":",
"r... | Convert an IP address from binary form into text represenation | [
"Convert",
"an",
"IP",
"address",
"from",
"binary",
"form",
"into",
"text",
"represenation"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/pton_ntop.py#L64-L90 | train |
phaethon/kamene | kamene/crypto/cert.py | strand | def strand(s1, s2):
"""
Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2
must be of same length.
"""
return "".join(map(lambda x,y:chr(ord(x)&ord(y)), s1, s2)) | python | def strand(s1, s2):
"""
Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2
must be of same length.
"""
return "".join(map(lambda x,y:chr(ord(x)&ord(y)), s1, s2)) | [
"def",
"strand",
"(",
"s1",
",",
"s2",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"map",
"(",
"lambda",
"x",
",",
"y",
":",
"chr",
"(",
"ord",
"(",
"x",
")",
"&",
"ord",
"(",
"y",
")",
")",
",",
"s1",
",",
"s2",
")",
")"
] | Returns the binary AND of the 2 provided strings s1 and s2. s1 and s2
must be of same length. | [
"Returns",
"the",
"binary",
"AND",
"of",
"the",
"2",
"provided",
"strings",
"s1",
"and",
"s2",
".",
"s1",
"and",
"s2",
"must",
"be",
"of",
"same",
"length",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L57-L62 | train |
phaethon/kamene | kamene/crypto/cert.py | pkcs_mgf1 | def pkcs_mgf1(mgfSeed, maskLen, h):
"""
Implements generic MGF1 Mask Generation function as described in
Appendix B.2.1 of RFC 3447. The hash function is passed by name.
valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256',
'sha384' and 'sha512'. Returns None on error.
Input:
mgf... | python | def pkcs_mgf1(mgfSeed, maskLen, h):
"""
Implements generic MGF1 Mask Generation function as described in
Appendix B.2.1 of RFC 3447. The hash function is passed by name.
valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256',
'sha384' and 'sha512'. Returns None on error.
Input:
mgf... | [
"def",
"pkcs_mgf1",
"(",
"mgfSeed",
",",
"maskLen",
",",
"h",
")",
":",
"if",
"not",
"h",
"in",
"_hashFuncParams",
":",
"warning",
"(",
"\"pkcs_mgf1: invalid hash (%s) provided\"",
")",
"return",
"None",
"hLen",
"=",
"_hashFuncParams",
"[",
"h",
"]",
"[",
"0... | Implements generic MGF1 Mask Generation function as described in
Appendix B.2.1 of RFC 3447. The hash function is passed by name.
valid values are 'md2', 'md4', 'md5', 'sha1', 'tls, 'sha256',
'sha384' and 'sha512'. Returns None on error.
Input:
mgfSeed: seed from which mask is generated, an octe... | [
"Implements",
"generic",
"MGF1",
"Mask",
"Generation",
"function",
"as",
"described",
"in",
"Appendix",
"B",
".",
"2",
".",
"1",
"of",
"RFC",
"3447",
".",
"The",
"hash",
"function",
"is",
"passed",
"by",
"name",
".",
"valid",
"values",
"are",
"md2",
"md4... | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L160-L195 | train |
phaethon/kamene | kamene/crypto/cert.py | create_temporary_ca_path | def create_temporary_ca_path(anchor_list, folder):
"""
Create a CA path folder as defined in OpenSSL terminology, by
storing all certificates in 'anchor_list' list in PEM format
under provided 'folder' and then creating the associated links
using the hash as usually done by c_rehash.
Note that ... | python | def create_temporary_ca_path(anchor_list, folder):
"""
Create a CA path folder as defined in OpenSSL terminology, by
storing all certificates in 'anchor_list' list in PEM format
under provided 'folder' and then creating the associated links
using the hash as usually done by c_rehash.
Note that ... | [
"def",
"create_temporary_ca_path",
"(",
"anchor_list",
",",
"folder",
")",
":",
"try",
":",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"folder",
")",
":",
"os",
".",
"makedirs",
"(",
"folder",
")",
"except",
":",
"return",
"None",
"l",
"=",
"... | Create a CA path folder as defined in OpenSSL terminology, by
storing all certificates in 'anchor_list' list in PEM format
under provided 'folder' and then creating the associated links
using the hash as usually done by c_rehash.
Note that you can also include CRL in 'anchor_list'. In that
case, th... | [
"Create",
"a",
"CA",
"path",
"folder",
"as",
"defined",
"in",
"OpenSSL",
"terminology",
"by",
"storing",
"all",
"certificates",
"in",
"anchor_list",
"list",
"in",
"PEM",
"format",
"under",
"provided",
"folder",
"and",
"then",
"creating",
"the",
"associated",
"... | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L382-L427 | train |
phaethon/kamene | kamene/crypto/cert.py | _DecryptAndSignMethods._rsadp | def _rsadp(self, c):
"""
Internal method providing raw RSA decryption, i.e. simple modular
exponentiation of the given ciphertext representative 'c', a long
between 0 and n-1.
This is the decryption primitive RSADP described in PKCS#1 v2.1,
i.e. RFC 3447 Sect. 5.1.2.
... | python | def _rsadp(self, c):
"""
Internal method providing raw RSA decryption, i.e. simple modular
exponentiation of the given ciphertext representative 'c', a long
between 0 and n-1.
This is the decryption primitive RSADP described in PKCS#1 v2.1,
i.e. RFC 3447 Sect. 5.1.2.
... | [
"def",
"_rsadp",
"(",
"self",
",",
"c",
")",
":",
"n",
"=",
"self",
".",
"modulus",
"if",
"type",
"(",
"c",
")",
"is",
"int",
":",
"c",
"=",
"long",
"(",
"c",
")",
"if",
"type",
"(",
"c",
")",
"is",
"not",
"long",
"or",
"c",
">",
"n",
"-"... | Internal method providing raw RSA decryption, i.e. simple modular
exponentiation of the given ciphertext representative 'c', a long
between 0 and n-1.
This is the decryption primitive RSADP described in PKCS#1 v2.1,
i.e. RFC 3447 Sect. 5.1.2.
Input:
c: ciphertest rep... | [
"Internal",
"method",
"providing",
"raw",
"RSA",
"decryption",
"i",
".",
"e",
".",
"simple",
"modular",
"exponentiation",
"of",
"the",
"given",
"ciphertext",
"representative",
"c",
"a",
"long",
"between",
"0",
"and",
"n",
"-",
"1",
"."
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/crypto/cert.py#L576-L602 | train |
phaethon/kamene | kamene/layers/inet.py | fragment | def fragment(pkt, fragsize=1480):
"""Fragment a big IP datagram"""
fragsize = (fragsize + 7) // 8 * 8
lst = []
for p in pkt:
s = bytes(p[IP].payload)
nb = (len(s) + fragsize - 1) // fragsize
for i in range(nb):
q = p.copy()
del q[IP].payload
de... | python | def fragment(pkt, fragsize=1480):
"""Fragment a big IP datagram"""
fragsize = (fragsize + 7) // 8 * 8
lst = []
for p in pkt:
s = bytes(p[IP].payload)
nb = (len(s) + fragsize - 1) // fragsize
for i in range(nb):
q = p.copy()
del q[IP].payload
de... | [
"def",
"fragment",
"(",
"pkt",
",",
"fragsize",
"=",
"1480",
")",
":",
"fragsize",
"=",
"(",
"fragsize",
"+",
"7",
")",
"//",
"8",
"*",
"8",
"lst",
"=",
"[",
"]",
"for",
"p",
"in",
"pkt",
":",
"s",
"=",
"bytes",
"(",
"p",
"[",
"IP",
"]",
".... | Fragment a big IP datagram | [
"Fragment",
"a",
"big",
"IP",
"datagram"
] | 11d4064844f4f68ac5d7546f5633ac7d02082914 | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/layers/inet.py#L864-L885 | train |
twitterdev/search-tweets-python | setup.py | parse_version | def parse_version(str_):
"""
Parses the program's version from a python variable declaration.
"""
v = re.findall(r"\d+.\d+.\d+", str_)
if v:
return v[0]
else:
print("cannot parse string {}".format(str_))
raise KeyError | python | def parse_version(str_):
"""
Parses the program's version from a python variable declaration.
"""
v = re.findall(r"\d+.\d+.\d+", str_)
if v:
return v[0]
else:
print("cannot parse string {}".format(str_))
raise KeyError | [
"def",
"parse_version",
"(",
"str_",
")",
":",
"v",
"=",
"re",
".",
"findall",
"(",
"r\"\\d+.\\d+.\\d+\"",
",",
"str_",
")",
"if",
"v",
":",
"return",
"v",
"[",
"0",
"]",
"else",
":",
"print",
"(",
"\"cannot parse string {}\"",
".",
"format",
"(",
"str... | Parses the program's version from a python variable declaration. | [
"Parses",
"the",
"program",
"s",
"version",
"from",
"a",
"python",
"variable",
"declaration",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/setup.py#L8-L17 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | make_session | def make_session(username=None, password=None, bearer_token=None, extra_headers_dict=None):
"""Creates a Requests Session for use. Accepts a bearer token
for premiums users and will override username and password information if
present.
Args:
username (str): username for the session
pa... | python | def make_session(username=None, password=None, bearer_token=None, extra_headers_dict=None):
"""Creates a Requests Session for use. Accepts a bearer token
for premiums users and will override username and password information if
present.
Args:
username (str): username for the session
pa... | [
"def",
"make_session",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"bearer_token",
"=",
"None",
",",
"extra_headers_dict",
"=",
"None",
")",
":",
"if",
"password",
"is",
"None",
"and",
"bearer_token",
"is",
"None",
":",
"logger",
".",
... | Creates a Requests Session for use. Accepts a bearer token
for premiums users and will override username and password information if
present.
Args:
username (str): username for the session
password (str): password for the user
bearer_token (str): token for a premium API user. | [
"Creates",
"a",
"Requests",
"Session",
"for",
"use",
".",
"Accepts",
"a",
"bearer",
"token",
"for",
"premiums",
"users",
"and",
"will",
"override",
"username",
"and",
"password",
"information",
"if",
"present",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L31-L61 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | retry | def retry(func):
"""
Decorator to handle API retries and exceptions. Defaults to three retries.
Args:
func (function): function for decoration
Returns:
decorated function
"""
def retried_func(*args, **kwargs):
max_tries = 3
tries = 0
while True:
... | python | def retry(func):
"""
Decorator to handle API retries and exceptions. Defaults to three retries.
Args:
func (function): function for decoration
Returns:
decorated function
"""
def retried_func(*args, **kwargs):
max_tries = 3
tries = 0
while True:
... | [
"def",
"retry",
"(",
"func",
")",
":",
"def",
"retried_func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"max_tries",
"=",
"3",
"tries",
"=",
"0",
"while",
"True",
":",
"try",
":",
"resp",
"=",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",... | Decorator to handle API retries and exceptions. Defaults to three retries.
Args:
func (function): function for decoration
Returns:
decorated function | [
"Decorator",
"to",
"handle",
"API",
"retries",
"and",
"exceptions",
".",
"Defaults",
"to",
"three",
"retries",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L64-L108 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | request | def request(session, url, rule_payload, **kwargs):
"""
Executes a request with the given payload and arguments.
Args:
session (requests.Session): the valid session object
url (str): Valid API endpoint
rule_payload (str or dict): rule package for the POST. If you pass a
d... | python | def request(session, url, rule_payload, **kwargs):
"""
Executes a request with the given payload and arguments.
Args:
session (requests.Session): the valid session object
url (str): Valid API endpoint
rule_payload (str or dict): rule package for the POST. If you pass a
d... | [
"def",
"request",
"(",
"session",
",",
"url",
",",
"rule_payload",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"rule_payload",
",",
"dict",
")",
":",
"rule_payload",
"=",
"json",
".",
"dumps",
"(",
"rule_payload",
")",
"logger",
".",
"debug",... | Executes a request with the given payload and arguments.
Args:
session (requests.Session): the valid session object
url (str): Valid API endpoint
rule_payload (str or dict): rule package for the POST. If you pass a
dictionary, it will be converted into JSON. | [
"Executes",
"a",
"request",
"with",
"the",
"given",
"payload",
"and",
"arguments",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L112-L126 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | collect_results | def collect_results(rule, max_results=500, result_stream_args=None):
"""
Utility function to quickly get a list of tweets from a ``ResultStream``
without keeping the object around. Requires your args to be configured
prior to using.
Args:
rule (str): valid powertrack rule for your account, ... | python | def collect_results(rule, max_results=500, result_stream_args=None):
"""
Utility function to quickly get a list of tweets from a ``ResultStream``
without keeping the object around. Requires your args to be configured
prior to using.
Args:
rule (str): valid powertrack rule for your account, ... | [
"def",
"collect_results",
"(",
"rule",
",",
"max_results",
"=",
"500",
",",
"result_stream_args",
"=",
"None",
")",
":",
"if",
"result_stream_args",
"is",
"None",
":",
"logger",
".",
"error",
"(",
"\"This function requires a configuration dict for the \"",
"\"inner Re... | Utility function to quickly get a list of tweets from a ``ResultStream``
without keeping the object around. Requires your args to be configured
prior to using.
Args:
rule (str): valid powertrack rule for your account, preferably
generated by the `gen_rule_payload` function.
max_resu... | [
"Utility",
"function",
"to",
"quickly",
"get",
"a",
"list",
"of",
"tweets",
"from",
"a",
"ResultStream",
"without",
"keeping",
"the",
"object",
"around",
".",
"Requires",
"your",
"args",
"to",
"be",
"configured",
"prior",
"to",
"using",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L276-L308 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | ResultStream.stream | def stream(self):
"""
Main entry point for the data from the API. Will automatically paginate
through the results via the ``next`` token and return up to ``max_results``
tweets or up to ``max_requests`` API calls, whichever is lower.
Usage:
>>> result_stream = Result... | python | def stream(self):
"""
Main entry point for the data from the API. Will automatically paginate
through the results via the ``next`` token and return up to ``max_results``
tweets or up to ``max_requests`` API calls, whichever is lower.
Usage:
>>> result_stream = Result... | [
"def",
"stream",
"(",
"self",
")",
":",
"self",
".",
"init_session",
"(",
")",
"self",
".",
"check_counts",
"(",
")",
"self",
".",
"execute_request",
"(",
")",
"self",
".",
"stream_started",
"=",
"True",
"while",
"True",
":",
"for",
"tweet",
"in",
"sel... | Main entry point for the data from the API. Will automatically paginate
through the results via the ``next`` token and return up to ``max_results``
tweets or up to ``max_requests`` API calls, whichever is lower.
Usage:
>>> result_stream = ResultStream(**kwargs)
>>> strea... | [
"Main",
"entry",
"point",
"for",
"the",
"data",
"from",
"the",
"API",
".",
"Will",
"automatically",
"paginate",
"through",
"the",
"results",
"via",
"the",
"next",
"token",
"and",
"return",
"up",
"to",
"max_results",
"tweets",
"or",
"up",
"to",
"max_requests"... | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L193-L227 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | ResultStream.init_session | def init_session(self):
"""
Defines a session object for passing requests.
"""
if self.session:
self.session.close()
self.session = make_session(self.username,
self.password,
self.bearer_token,
... | python | def init_session(self):
"""
Defines a session object for passing requests.
"""
if self.session:
self.session.close()
self.session = make_session(self.username,
self.password,
self.bearer_token,
... | [
"def",
"init_session",
"(",
"self",
")",
":",
"if",
"self",
".",
"session",
":",
"self",
".",
"session",
".",
"close",
"(",
")",
"self",
".",
"session",
"=",
"make_session",
"(",
"self",
".",
"username",
",",
"self",
".",
"password",
",",
"self",
"."... | Defines a session object for passing requests. | [
"Defines",
"a",
"session",
"object",
"for",
"passing",
"requests",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L229-L238 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | ResultStream.check_counts | def check_counts(self):
"""
Disables tweet parsing if the count API is used.
"""
if "counts" in re.split("[/.]", self.endpoint):
logger.info("disabling tweet parsing due to counts API usage")
self._tweet_func = lambda x: x | python | def check_counts(self):
"""
Disables tweet parsing if the count API is used.
"""
if "counts" in re.split("[/.]", self.endpoint):
logger.info("disabling tweet parsing due to counts API usage")
self._tweet_func = lambda x: x | [
"def",
"check_counts",
"(",
"self",
")",
":",
"if",
"\"counts\"",
"in",
"re",
".",
"split",
"(",
"\"[/.]\"",
",",
"self",
".",
"endpoint",
")",
":",
"logger",
".",
"info",
"(",
"\"disabling tweet parsing due to counts API usage\"",
")",
"self",
".",
"_tweet_fu... | Disables tweet parsing if the count API is used. | [
"Disables",
"tweet",
"parsing",
"if",
"the",
"count",
"API",
"is",
"used",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L240-L246 | train |
twitterdev/search-tweets-python | searchtweets/result_stream.py | ResultStream.execute_request | def execute_request(self):
"""
Sends the request to the API and parses the json response.
Makes some assumptions about the session length and sets the presence
of a "next" token.
"""
if self.n_requests % 20 == 0 and self.n_requests > 1:
logger.info("refreshing... | python | def execute_request(self):
"""
Sends the request to the API and parses the json response.
Makes some assumptions about the session length and sets the presence
of a "next" token.
"""
if self.n_requests % 20 == 0 and self.n_requests > 1:
logger.info("refreshing... | [
"def",
"execute_request",
"(",
"self",
")",
":",
"if",
"self",
".",
"n_requests",
"%",
"20",
"==",
"0",
"and",
"self",
".",
"n_requests",
">",
"1",
":",
"logger",
".",
"info",
"(",
"\"refreshing session\"",
")",
"self",
".",
"init_session",
"(",
")",
"... | Sends the request to the API and parses the json response.
Makes some assumptions about the session length and sets the presence
of a "next" token. | [
"Sends",
"the",
"request",
"to",
"the",
"API",
"and",
"parses",
"the",
"json",
"response",
".",
"Makes",
"some",
"assumptions",
"about",
"the",
"session",
"length",
"and",
"sets",
"the",
"presence",
"of",
"a",
"next",
"token",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/result_stream.py#L248-L265 | train |
twitterdev/search-tweets-python | searchtweets/api_utils.py | gen_rule_payload | def gen_rule_payload(pt_rule, results_per_call=None,
from_date=None, to_date=None, count_bucket=None,
tag=None,
stringify=True):
"""
Generates the dict or json payload for a PowerTrack rule.
Args:
pt_rule (str): The string version of a... | python | def gen_rule_payload(pt_rule, results_per_call=None,
from_date=None, to_date=None, count_bucket=None,
tag=None,
stringify=True):
"""
Generates the dict or json payload for a PowerTrack rule.
Args:
pt_rule (str): The string version of a... | [
"def",
"gen_rule_payload",
"(",
"pt_rule",
",",
"results_per_call",
"=",
"None",
",",
"from_date",
"=",
"None",
",",
"to_date",
"=",
"None",
",",
"count_bucket",
"=",
"None",
",",
"tag",
"=",
"None",
",",
"stringify",
"=",
"True",
")",
":",
"pt_rule",
"=... | Generates the dict or json payload for a PowerTrack rule.
Args:
pt_rule (str): The string version of a powertrack rule,
e.g., "beyonce has:geo". Accepts multi-line strings
for ease of entry.
results_per_call (int): number of tweets or counts returned per API
call. Th... | [
"Generates",
"the",
"dict",
"or",
"json",
"payload",
"for",
"a",
"PowerTrack",
"rule",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L86-L138 | train |
twitterdev/search-tweets-python | searchtweets/api_utils.py | gen_params_from_config | def gen_params_from_config(config_dict):
"""
Generates parameters for a ResultStream from a dictionary.
"""
if config_dict.get("count_bucket"):
logger.warning("change your endpoint to the count endpoint; this is "
"default behavior when the count bucket "
... | python | def gen_params_from_config(config_dict):
"""
Generates parameters for a ResultStream from a dictionary.
"""
if config_dict.get("count_bucket"):
logger.warning("change your endpoint to the count endpoint; this is "
"default behavior when the count bucket "
... | [
"def",
"gen_params_from_config",
"(",
"config_dict",
")",
":",
"if",
"config_dict",
".",
"get",
"(",
"\"count_bucket\"",
")",
":",
"logger",
".",
"warning",
"(",
"\"change your endpoint to the count endpoint; this is \"",
"\"default behavior when the count bucket \"",
"\"fiel... | Generates parameters for a ResultStream from a dictionary. | [
"Generates",
"parameters",
"for",
"a",
"ResultStream",
"from",
"a",
"dictionary",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L141-L179 | train |
twitterdev/search-tweets-python | searchtweets/api_utils.py | infer_endpoint | def infer_endpoint(rule_payload):
"""
Infer which endpoint should be used for a given rule payload.
"""
bucket = (rule_payload if isinstance(rule_payload, dict)
else json.loads(rule_payload)).get("bucket")
return "counts" if bucket else "search" | python | def infer_endpoint(rule_payload):
"""
Infer which endpoint should be used for a given rule payload.
"""
bucket = (rule_payload if isinstance(rule_payload, dict)
else json.loads(rule_payload)).get("bucket")
return "counts" if bucket else "search" | [
"def",
"infer_endpoint",
"(",
"rule_payload",
")",
":",
"bucket",
"=",
"(",
"rule_payload",
"if",
"isinstance",
"(",
"rule_payload",
",",
"dict",
")",
"else",
"json",
".",
"loads",
"(",
"rule_payload",
")",
")",
".",
"get",
"(",
"\"bucket\"",
")",
"return"... | Infer which endpoint should be used for a given rule payload. | [
"Infer",
"which",
"endpoint",
"should",
"be",
"used",
"for",
"a",
"given",
"rule",
"payload",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L182-L188 | train |
twitterdev/search-tweets-python | searchtweets/api_utils.py | validate_count_api | def validate_count_api(rule_payload, endpoint):
"""
Ensures that the counts api is set correctly in a payload.
"""
rule = (rule_payload if isinstance(rule_payload, dict)
else json.loads(rule_payload))
bucket = rule.get('bucket')
counts = set(endpoint.split("/")) & {"counts.json"}
... | python | def validate_count_api(rule_payload, endpoint):
"""
Ensures that the counts api is set correctly in a payload.
"""
rule = (rule_payload if isinstance(rule_payload, dict)
else json.loads(rule_payload))
bucket = rule.get('bucket')
counts = set(endpoint.split("/")) & {"counts.json"}
... | [
"def",
"validate_count_api",
"(",
"rule_payload",
",",
"endpoint",
")",
":",
"rule",
"=",
"(",
"rule_payload",
"if",
"isinstance",
"(",
"rule_payload",
",",
"dict",
")",
"else",
"json",
".",
"loads",
"(",
"rule_payload",
")",
")",
"bucket",
"=",
"rule",
".... | Ensures that the counts api is set correctly in a payload. | [
"Ensures",
"that",
"the",
"counts",
"api",
"is",
"set",
"correctly",
"in",
"a",
"payload",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/api_utils.py#L191-L205 | train |
twitterdev/search-tweets-python | searchtweets/utils.py | partition | def partition(iterable, chunk_size, pad_none=False):
"""adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
... | python | def partition(iterable, chunk_size, pad_none=False):
"""adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
... | [
"def",
"partition",
"(",
"iterable",
",",
"chunk_size",
",",
"pad_none",
"=",
"False",
")",
":",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"chunk_size",
"if",
"not",
"pad_none",
":",
"return",
"zip",
"(",
"*",
"args",
")",
"else",
":"... | adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
[(0, 1, 2), (3, 4, 5), (6, 7, 8)]
>>> list(part... | [
"adapted",
"from",
"Toolz",
".",
"Breaks",
"an",
"iterable",
"into",
"n",
"iterables",
"up",
"to",
"the",
"certain",
"chunk",
"size",
"padding",
"with",
"Nones",
"if",
"availble",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L41-L57 | train |
twitterdev/search-tweets-python | searchtweets/utils.py | write_ndjson | def write_ndjson(filename, data_iterable, append=False, **kwargs):
"""
Generator that writes newline-delimited json to a file and returns items
from an iterable.
"""
write_mode = "ab" if append else "wb"
logger.info("writing to file {}".format(filename))
with codecs.open(filename, write_mode... | python | def write_ndjson(filename, data_iterable, append=False, **kwargs):
"""
Generator that writes newline-delimited json to a file and returns items
from an iterable.
"""
write_mode = "ab" if append else "wb"
logger.info("writing to file {}".format(filename))
with codecs.open(filename, write_mode... | [
"def",
"write_ndjson",
"(",
"filename",
",",
"data_iterable",
",",
"append",
"=",
"False",
",",
"**",
"kwargs",
")",
":",
"write_mode",
"=",
"\"ab\"",
"if",
"append",
"else",
"\"wb\"",
"logger",
".",
"info",
"(",
"\"writing to file {}\"",
".",
"format",
"(",... | Generator that writes newline-delimited json to a file and returns items
from an iterable. | [
"Generator",
"that",
"writes",
"newline",
"-",
"delimited",
"json",
"to",
"a",
"file",
"and",
"returns",
"items",
"from",
"an",
"iterable",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L87-L97 | train |
twitterdev/search-tweets-python | searchtweets/utils.py | write_result_stream | def write_result_stream(result_stream, filename_prefix=None,
results_per_file=None, **kwargs):
"""
Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Arg... | python | def write_result_stream(result_stream, filename_prefix=None,
results_per_file=None, **kwargs):
"""
Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Arg... | [
"def",
"write_result_stream",
"(",
"result_stream",
",",
"filename_prefix",
"=",
"None",
",",
"results_per_file",
"=",
"None",
",",
"**",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"result_stream",
",",
"types",
".",
"GeneratorType",
")",
":",
"stream",
"=",... | Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Args:
result_stream (ResultStream): the unstarted ResultStream object
filename_prefix (str or None): the base name for... | [
"Wraps",
"a",
"ResultStream",
"object",
"to",
"save",
"it",
"to",
"a",
"file",
".",
"This",
"function",
"will",
"still",
"return",
"all",
"data",
"from",
"the",
"result",
"stream",
"as",
"a",
"generator",
"that",
"wraps",
"the",
"write_ndjson",
"method",
"... | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L100-L140 | train |
twitterdev/search-tweets-python | searchtweets/credentials.py | _load_yaml_credentials | def _load_yaml_credentials(filename=None, yaml_key=None):
"""Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {}
"""
try:
with open(os.path.expanduser(fil... | python | def _load_yaml_credentials(filename=None, yaml_key=None):
"""Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {}
"""
try:
with open(os.path.expanduser(fil... | [
"def",
"_load_yaml_credentials",
"(",
"filename",
"=",
"None",
",",
"yaml_key",
"=",
"None",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"as",
"f",
":",
"search_creds",
"=",
"yaml",
".",
... | Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {} | [
"Loads",
"and",
"parses",
"credentials",
"in",
"a",
"YAML",
"file",
".",
"Catches",
"common",
"exceptions",
"and",
"returns",
"an",
"empty",
"dict",
"on",
"error",
"which",
"will",
"be",
"handled",
"downstream",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/credentials.py#L25-L43 | train |
twitterdev/search-tweets-python | searchtweets/credentials.py | _generate_bearer_token | def _generate_bearer_token(consumer_key, consumer_secret):
"""
Return the bearer token for a given pair of consumer key and secret values.
"""
data = [('grant_type', 'client_credentials')]
resp = requests.post(OAUTH_ENDPOINT,
data=data,
auth=(consume... | python | def _generate_bearer_token(consumer_key, consumer_secret):
"""
Return the bearer token for a given pair of consumer key and secret values.
"""
data = [('grant_type', 'client_credentials')]
resp = requests.post(OAUTH_ENDPOINT,
data=data,
auth=(consume... | [
"def",
"_generate_bearer_token",
"(",
"consumer_key",
",",
"consumer_secret",
")",
":",
"data",
"=",
"[",
"(",
"'grant_type'",
",",
"'client_credentials'",
")",
"]",
"resp",
"=",
"requests",
".",
"post",
"(",
"OAUTH_ENDPOINT",
",",
"data",
"=",
"data",
",",
... | Return the bearer token for a given pair of consumer key and secret values. | [
"Return",
"the",
"bearer",
"token",
"for",
"a",
"given",
"pair",
"of",
"consumer",
"key",
"and",
"secret",
"values",
"."
] | 7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5 | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/credentials.py#L193-L206 | train |
kvesteri/validators | validators/i18n/fi.py | fi_business_id | def fi_business_id(business_id):
"""
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_busine... | python | def fi_business_id(business_id):
"""
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_busine... | [
"def",
"fi_business_id",
"(",
"business_id",
")",
":",
"if",
"not",
"business_id",
"or",
"not",
"re",
".",
"match",
"(",
"business_id_pattern",
",",
"business_id",
")",
":",
"return",
"False",
"factors",
"=",
"[",
"7",
",",
"9",
",",
"10",
",",
"5",
",... | Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_business_id('0112038-9') # Fast Monkeys Ltd
... | [
"Validate",
"a",
"Finnish",
"Business",
"ID",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/i18n/fi.py#L20-L51 | train |
kvesteri/validators | validators/i18n/fi.py | fi_ssn | def fi_ssn(ssn, allow_temporal_ssn=True):
"""
Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>>... | python | def fi_ssn(ssn, allow_temporal_ssn=True):
"""
Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>>... | [
"def",
"fi_ssn",
"(",
"ssn",
",",
"allow_temporal_ssn",
"=",
"True",
")",
":",
"if",
"not",
"ssn",
":",
"return",
"False",
"result",
"=",
"re",
".",
"match",
"(",
"ssn_pattern",
",",
"ssn",
")",
"if",
"not",
"result",
":",
"return",
"False",
"gd",
"=... | Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>> fi_ssn('101010-0102')
ValidationFailure(func=... | [
"Validate",
"a",
"Finnish",
"Social",
"Security",
"Number",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/i18n/fi.py#L55-L94 | train |
kvesteri/validators | validators/iban.py | modcheck | def modcheck(value):
"""Check if the value string passes the mod97-test.
"""
# move country code and check numbers to end
rearranged = value[4:] + value[:4]
# convert letters to numbers
converted = [char_value(char) for char in rearranged]
# interpret as integer
integerized = int(''.join... | python | def modcheck(value):
"""Check if the value string passes the mod97-test.
"""
# move country code and check numbers to end
rearranged = value[4:] + value[:4]
# convert letters to numbers
converted = [char_value(char) for char in rearranged]
# interpret as integer
integerized = int(''.join... | [
"def",
"modcheck",
"(",
"value",
")",
":",
"rearranged",
"=",
"value",
"[",
"4",
":",
"]",
"+",
"value",
"[",
":",
"4",
"]",
"converted",
"=",
"[",
"char_value",
"(",
"char",
")",
"for",
"char",
"in",
"rearranged",
"]",
"integerized",
"=",
"int",
"... | Check if the value string passes the mod97-test. | [
"Check",
"if",
"the",
"value",
"string",
"passes",
"the",
"mod97",
"-",
"test",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/iban.py#L20-L29 | train |
kvesteri/validators | validators/utils.py | func_args_as_dict | def func_args_as_dict(func, args, kwargs):
"""
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
arg_names = list(
OrderedDict.fromkeys(
... | python | def func_args_as_dict(func, args, kwargs):
"""
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
arg_names = list(
OrderedDict.fromkeys(
... | [
"def",
"func_args_as_dict",
"(",
"func",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"six",
".",
"PY2",
":",
"_getargspec",
"=",
"inspect",
".",
"getargspec",
"else",
":",
"_getargspec",
"=",
"inspect",
".",
"getfullargspec",
"arg_names",
"=",
"list",
"(",... | Return given function's positional and key value arguments as an ordered
dictionary. | [
"Return",
"given",
"function",
"s",
"positional",
"and",
"key",
"value",
"arguments",
"as",
"an",
"ordered",
"dictionary",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/utils.py#L35-L56 | train |
kvesteri/validators | validators/utils.py | validator | def validator(func, *args, **kwargs):
"""
A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... retu... | python | def validator(func, *args, **kwargs):
"""
A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... retu... | [
"def",
"validator",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"func",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"value",
"=",
"func",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"not",
"va... | A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... return not (value % 2)
>>> even(4)
Tr... | [
"A",
"decorator",
"that",
"makes",
"given",
"function",
"validator",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/utils.py#L59-L89 | train |
kvesteri/validators | validators/length.py | length | def length(value, min=None, max=None):
"""
Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
Validation... | python | def length(value, min=None, max=None):
"""
Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
Validation... | [
"def",
"length",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"if",
"(",
"min",
"is",
"not",
"None",
"and",
"min",
"<",
"0",
")",
"or",
"(",
"max",
"is",
"not",
"None",
"and",
"max",
"<",
"0",
")",
":",
"raise",
... | Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
ValidationFailure(func=length, ...)
:param value:
... | [
"Return",
"whether",
"or",
"not",
"the",
"length",
"of",
"given",
"string",
"is",
"within",
"a",
"specified",
"range",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/length.py#L6-L37 | train |
kvesteri/validators | validators/url.py | url | def url(value, public=False):
"""
Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dper... | python | def url(value, public=False):
"""
Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dper... | [
"def",
"url",
"(",
"value",
",",
"public",
"=",
"False",
")",
":",
"result",
"=",
"pattern",
".",
"match",
"(",
"value",
")",
"if",
"not",
"public",
":",
"return",
"result",
"return",
"result",
"and",
"not",
"any",
"(",
"(",
"result",
".",
"groupdict... | Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dperini:
https://gist.github.com/dperi... | [
"Return",
"whether",
"or",
"not",
"given",
"value",
"is",
"a",
"valid",
"URL",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/url.py#L94-L151 | train |
kvesteri/validators | validators/ip_address.py | ipv4 | def ipv4(value):
"""
Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
... | python | def ipv4(value):
"""
Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
... | [
"def",
"ipv4",
"(",
"value",
")",
":",
"groups",
"=",
"value",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"groups",
")",
"!=",
"4",
"or",
"any",
"(",
"not",
"x",
".",
"isdigit",
"(",
")",
"for",
"x",
"in",
"groups",
")",
":",
"return",
... | Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
True
>>> ipv... | [
"Return",
"whether",
"or",
"not",
"given",
"value",
"is",
"a",
"valid",
"IP",
"version",
"4",
"address",
"."
] | 34d355e87168241e872b25811d245810df2bd430 | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/ip_address.py#L5-L29 | train |
eddyxu/cpp-coveralls | cpp_coveralls/report.py | post_report | def post_report(coverage, args):
"""Post coverage report to coveralls.io."""
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
verify=(not args.skip_ssl_verify))
try:
result = response.json()
except ValueError:
result = {'error': 'Failu... | python | def post_report(coverage, args):
"""Post coverage report to coveralls.io."""
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
verify=(not args.skip_ssl_verify))
try:
result = response.json()
except ValueError:
result = {'error': 'Failu... | [
"def",
"post_report",
"(",
"coverage",
",",
"args",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"URL",
",",
"files",
"=",
"{",
"'json_file'",
":",
"json",
".",
"dumps",
"(",
"coverage",
")",
"}",
",",
"verify",
"=",
"(",
"not",
"args",
... | Post coverage report to coveralls.io. | [
"Post",
"coverage",
"report",
"to",
"coveralls",
".",
"io",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/report.py#L10-L24 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | is_source_file | def is_source_file(args, filepath):
"""Returns true if it is a C++ source file."""
if args.extension:
return os.path.splitext(filepath)[1] in args.extension
else:
return os.path.splitext(filepath)[1] in _CPP_EXTENSIONS | python | def is_source_file(args, filepath):
"""Returns true if it is a C++ source file."""
if args.extension:
return os.path.splitext(filepath)[1] in args.extension
else:
return os.path.splitext(filepath)[1] in _CPP_EXTENSIONS | [
"def",
"is_source_file",
"(",
"args",
",",
"filepath",
")",
":",
"if",
"args",
".",
"extension",
":",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"filepath",
")",
"[",
"1",
"]",
"in",
"args",
".",
"extension",
"else",
":",
"return",
"os",
".",... | Returns true if it is a C++ source file. | [
"Returns",
"true",
"if",
"it",
"is",
"a",
"C",
"++",
"source",
"file",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L93-L98 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | exclude_paths | def exclude_paths(args):
"""Returns the absolute paths for excluded path."""
results = []
if args.exclude:
for excl_path in args.exclude:
results.append(os.path.abspath(os.path.join(args.root, excl_path)))
return results | python | def exclude_paths(args):
"""Returns the absolute paths for excluded path."""
results = []
if args.exclude:
for excl_path in args.exclude:
results.append(os.path.abspath(os.path.join(args.root, excl_path)))
return results | [
"def",
"exclude_paths",
"(",
"args",
")",
":",
"results",
"=",
"[",
"]",
"if",
"args",
".",
"exclude",
":",
"for",
"excl_path",
"in",
"args",
".",
"exclude",
":",
"results",
".",
"append",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"pa... | Returns the absolute paths for excluded path. | [
"Returns",
"the",
"absolute",
"paths",
"for",
"excluded",
"path",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L101-L107 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | create_exclude_rules | def create_exclude_rules(args):
"""Creates the exlude rules
"""
global _cached_exclude_rules
if _cached_exclude_rules is not None:
return _cached_exclude_rules
rules = []
for excl_path in args.exclude:
abspath = os.path.abspath(os.path.join(args.root, excl_path))
rules.ap... | python | def create_exclude_rules(args):
"""Creates the exlude rules
"""
global _cached_exclude_rules
if _cached_exclude_rules is not None:
return _cached_exclude_rules
rules = []
for excl_path in args.exclude:
abspath = os.path.abspath(os.path.join(args.root, excl_path))
rules.ap... | [
"def",
"create_exclude_rules",
"(",
"args",
")",
":",
"global",
"_cached_exclude_rules",
"if",
"_cached_exclude_rules",
"is",
"not",
"None",
":",
"return",
"_cached_exclude_rules",
"rules",
"=",
"[",
"]",
"for",
"excl_path",
"in",
"args",
".",
"exclude",
":",
"a... | Creates the exlude rules | [
"Creates",
"the",
"exlude",
"rules"
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L113-L127 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | is_excluded_path | def is_excluded_path(args, filepath):
"""Returns true if the filepath is under the one of the exclude path."""
# Try regular expressions first.
for regexp_exclude_path in args.regexp:
if re.match(regexp_exclude_path, filepath):
return True
abspath = os.path.abspath(filepath)
if a... | python | def is_excluded_path(args, filepath):
"""Returns true if the filepath is under the one of the exclude path."""
# Try regular expressions first.
for regexp_exclude_path in args.regexp:
if re.match(regexp_exclude_path, filepath):
return True
abspath = os.path.abspath(filepath)
if a... | [
"def",
"is_excluded_path",
"(",
"args",
",",
"filepath",
")",
":",
"for",
"regexp_exclude_path",
"in",
"args",
".",
"regexp",
":",
"if",
"re",
".",
"match",
"(",
"regexp_exclude_path",
",",
"filepath",
")",
":",
"return",
"True",
"abspath",
"=",
"os",
".",... | Returns true if the filepath is under the one of the exclude path. | [
"Returns",
"true",
"if",
"the",
"filepath",
"is",
"under",
"the",
"one",
"of",
"the",
"exclude",
"path",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L135-L166 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | filter_dirs | def filter_dirs(root, dirs, excl_paths):
"""Filter directory paths based on the exclusion rules defined in
'excl_paths'.
"""
filtered_dirs = []
for dirpath in dirs:
abspath = os.path.abspath(os.path.join(root, dirpath))
if os.path.basename(abspath) in _SKIP_DIRS:
continue... | python | def filter_dirs(root, dirs, excl_paths):
"""Filter directory paths based on the exclusion rules defined in
'excl_paths'.
"""
filtered_dirs = []
for dirpath in dirs:
abspath = os.path.abspath(os.path.join(root, dirpath))
if os.path.basename(abspath) in _SKIP_DIRS:
continue... | [
"def",
"filter_dirs",
"(",
"root",
",",
"dirs",
",",
"excl_paths",
")",
":",
"filtered_dirs",
"=",
"[",
"]",
"for",
"dirpath",
"in",
"dirs",
":",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
"... | Filter directory paths based on the exclusion rules defined in
'excl_paths'. | [
"Filter",
"directory",
"paths",
"based",
"on",
"the",
"exclusion",
"rules",
"defined",
"in",
"excl_paths",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L186-L197 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | parse_gcov_file | def parse_gcov_file(args, fobj, filename):
"""Parses the content of .gcov file
"""
coverage = []
ignoring = False
for line in fobj:
report_fields = line.decode('utf-8', 'replace').split(':', 2)
if len(report_fields) == 1:
continue
line_num = report_fields[1].strip... | python | def parse_gcov_file(args, fobj, filename):
"""Parses the content of .gcov file
"""
coverage = []
ignoring = False
for line in fobj:
report_fields = line.decode('utf-8', 'replace').split(':', 2)
if len(report_fields) == 1:
continue
line_num = report_fields[1].strip... | [
"def",
"parse_gcov_file",
"(",
"args",
",",
"fobj",
",",
"filename",
")",
":",
"coverage",
"=",
"[",
"]",
"ignoring",
"=",
"False",
"for",
"line",
"in",
"fobj",
":",
"report_fields",
"=",
"line",
".",
"decode",
"(",
"'utf-8'",
",",
"'replace'",
")",
".... | Parses the content of .gcov file | [
"Parses",
"the",
"content",
"of",
".",
"gcov",
"file"
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L247-L296 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | parse_lcov_file_info | def parse_lcov_file_info(args, filepath, line_iter, line_coverage_re, file_end_string):
""" Parse the file content in lcov info file
"""
coverage = []
lines_covered = []
for line in line_iter:
if line != "end_of_record":
line_coverage_match = line_coverage_re.match(line)
... | python | def parse_lcov_file_info(args, filepath, line_iter, line_coverage_re, file_end_string):
""" Parse the file content in lcov info file
"""
coverage = []
lines_covered = []
for line in line_iter:
if line != "end_of_record":
line_coverage_match = line_coverage_re.match(line)
... | [
"def",
"parse_lcov_file_info",
"(",
"args",
",",
"filepath",
",",
"line_iter",
",",
"line_coverage_re",
",",
"file_end_string",
")",
":",
"coverage",
"=",
"[",
"]",
"lines_covered",
"=",
"[",
"]",
"for",
"line",
"in",
"line_iter",
":",
"if",
"line",
"!=",
... | Parse the file content in lcov info file | [
"Parse",
"the",
"file",
"content",
"in",
"lcov",
"info",
"file"
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L299-L322 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | combine_reports | def combine_reports(original, new):
"""Combines two gcov reports for a file into one by adding the number of hits on each line
"""
if original is None:
return new
report = {}
report['name'] = original['name']
report['source_digest'] = original['source_digest']
coverage = []
for o... | python | def combine_reports(original, new):
"""Combines two gcov reports for a file into one by adding the number of hits on each line
"""
if original is None:
return new
report = {}
report['name'] = original['name']
report['source_digest'] = original['source_digest']
coverage = []
for o... | [
"def",
"combine_reports",
"(",
"original",
",",
"new",
")",
":",
"if",
"original",
"is",
"None",
":",
"return",
"new",
"report",
"=",
"{",
"}",
"report",
"[",
"'name'",
"]",
"=",
"original",
"[",
"'name'",
"]",
"report",
"[",
"'source_digest'",
"]",
"=... | Combines two gcov reports for a file into one by adding the number of hits on each line | [
"Combines",
"two",
"gcov",
"reports",
"for",
"a",
"file",
"into",
"one",
"by",
"adding",
"the",
"number",
"of",
"hits",
"on",
"each",
"line"
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L324-L342 | train |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | collect_non_report_files | def collect_non_report_files(args, discovered_files):
"""Collects the source files that have no coverage reports.
"""
excl_paths = exclude_paths(args)
abs_root = os.path.abspath(args.root)
non_report_files = []
for root, dirs, files in os.walk(args.root, followlinks=args.follow_symlinks):
... | python | def collect_non_report_files(args, discovered_files):
"""Collects the source files that have no coverage reports.
"""
excl_paths = exclude_paths(args)
abs_root = os.path.abspath(args.root)
non_report_files = []
for root, dirs, files in os.walk(args.root, followlinks=args.follow_symlinks):
... | [
"def",
"collect_non_report_files",
"(",
"args",
",",
"discovered_files",
")",
":",
"excl_paths",
"=",
"exclude_paths",
"(",
"args",
")",
"abs_root",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"args",
".",
"root",
")",
"non_report_files",
"=",
"[",
"]",
"... | Collects the source files that have no coverage reports. | [
"Collects",
"the",
"source",
"files",
"that",
"have",
"no",
"coverage",
"reports",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L344-L371 | train |
eddyxu/cpp-coveralls | cpp_coveralls/__init__.py | parse_yaml_config | def parse_yaml_config(args):
"""Parse yaml config"""
try:
import yaml
except ImportError:
yaml = None
yml = {}
try:
with open(args.coveralls_yaml, 'r') as fp:
if not yaml:
raise SystemExit('PyYAML is required for parsing configuration')
... | python | def parse_yaml_config(args):
"""Parse yaml config"""
try:
import yaml
except ImportError:
yaml = None
yml = {}
try:
with open(args.coveralls_yaml, 'r') as fp:
if not yaml:
raise SystemExit('PyYAML is required for parsing configuration')
... | [
"def",
"parse_yaml_config",
"(",
"args",
")",
":",
"try",
":",
"import",
"yaml",
"except",
"ImportError",
":",
"yaml",
"=",
"None",
"yml",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"args",
".",
"coveralls_yaml",
",",
"'r'",
")",
"as",
"fp",
":"... | Parse yaml config | [
"Parse",
"yaml",
"config"
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/__init__.py#L37-L53 | train |
eddyxu/cpp-coveralls | cpp_coveralls/__init__.py | run | def run():
"""Run cpp coverage."""
import json
import os
import sys
from . import coverage, report
args = coverage.create_args(sys.argv[1:])
if args.verbose:
print('encodings: {}'.format(args.encodings))
yml = parse_yaml_config(args)
if not args.repo_token:
# try ... | python | def run():
"""Run cpp coverage."""
import json
import os
import sys
from . import coverage, report
args = coverage.create_args(sys.argv[1:])
if args.verbose:
print('encodings: {}'.format(args.encodings))
yml = parse_yaml_config(args)
if not args.repo_token:
# try ... | [
"def",
"run",
"(",
")",
":",
"import",
"json",
"import",
"os",
"import",
"sys",
"from",
".",
"import",
"coverage",
",",
"report",
"args",
"=",
"coverage",
".",
"create_args",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"if",
"args",
".",
"ver... | Run cpp coverage. | [
"Run",
"cpp",
"coverage",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/__init__.py#L55-L106 | train |
eddyxu/cpp-coveralls | cpp_coveralls/gitrepo.py | gitrepo | def gitrepo(cwd):
"""Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.c... | python | def gitrepo(cwd):
"""Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.c... | [
"def",
"gitrepo",
"(",
"cwd",
")",
":",
"repo",
"=",
"Repository",
"(",
"cwd",
")",
"if",
"not",
"repo",
".",
"valid",
"(",
")",
":",
"return",
"{",
"}",
"return",
"{",
"'head'",
":",
"{",
"'id'",
":",
"repo",
".",
"gitlog",
"(",
"'%H'",
")",
"... | Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.com",
"com... | [
"Return",
"hash",
"of",
"Git",
"data",
"that",
"can",
"be",
"used",
"to",
"display",
"more",
"information",
"to",
"users",
"."
] | ff7af7eea2a23828f6ab2541667ea04f94344dce | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/gitrepo.py#L7-L49 | train |
vitiral/gpio | gpio.py | _verify | def _verify(function):
"""decorator to ensure pin is properly set up"""
# @functools.wraps
def wrapped(pin, *args, **kwargs):
pin = int(pin)
if pin not in _open:
ppath = gpiopath(pin)
if not os.path.exists(ppath):
log.debug("Creating Pin {0}".f... | python | def _verify(function):
"""decorator to ensure pin is properly set up"""
# @functools.wraps
def wrapped(pin, *args, **kwargs):
pin = int(pin)
if pin not in _open:
ppath = gpiopath(pin)
if not os.path.exists(ppath):
log.debug("Creating Pin {0}".f... | [
"def",
"_verify",
"(",
"function",
")",
":",
"def",
"wrapped",
"(",
"pin",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"pin",
"=",
"int",
"(",
"pin",
")",
"if",
"pin",
"not",
"in",
"_open",
":",
"ppath",
"=",
"gpiopath",
"(",
"pin",
")",
"... | decorator to ensure pin is properly set up | [
"decorator",
"to",
"ensure",
"pin",
"is",
"properly",
"set",
"up"
] | d4d8bdc6965295b978eca882e2e2e5a1b35e047b | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L54-L70 | train |
vitiral/gpio | gpio.py | set | def set(pin, value):
'''set the pin value to 0 or 1'''
if value is LOW:
value = 0
value = int(bool(value))
log.debug("Write {0}: {1}".format(pin, value))
f = _open[pin].value
_write(f, value) | python | def set(pin, value):
'''set the pin value to 0 or 1'''
if value is LOW:
value = 0
value = int(bool(value))
log.debug("Write {0}: {1}".format(pin, value))
f = _open[pin].value
_write(f, value) | [
"def",
"set",
"(",
"pin",
",",
"value",
")",
":",
"if",
"value",
"is",
"LOW",
":",
"value",
"=",
"0",
"value",
"=",
"int",
"(",
"bool",
"(",
"value",
")",
")",
"log",
".",
"debug",
"(",
"\"Write {0}: {1}\"",
".",
"format",
"(",
"pin",
",",
"value... | set the pin value to 0 or 1 | [
"set",
"the",
"pin",
"value",
"to",
"0",
"or",
"1"
] | d4d8bdc6965295b978eca882e2e2e5a1b35e047b | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L158-L165 | train |
fhs/pyhdf | pyhdf/V.py | V.end | def end(self):
"""Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend
"""
# Note: Vend is just a macro; use 'Vfinish' instead
# Note also the the same C function is ... | python | def end(self):
"""Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend
"""
# Note: Vend is just a macro; use 'Vfinish' instead
# Note also the the same C function is ... | [
"def",
"end",
"(",
"self",
")",
":",
"_checkErr",
"(",
"'vend'",
",",
"_C",
".",
"Vfinish",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
")",
",",
"\"cannot terminate V interface\"",
")",
"self",
".",
"_hdf_inst",
"=",
"None"
] | Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend | [
"Close",
"the",
"V",
"interface",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L704-L723 | train |
fhs/pyhdf | pyhdf/V.py | V.attach | def attach(self, num_name, write=0):
"""Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to creat... | python | def attach(self, num_name, write=0):
"""Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to creat... | [
"def",
"attach",
"(",
"self",
",",
"num_name",
",",
"write",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"num_name",
",",
"bytes",
")",
":",
"num",
"=",
"self",
".",
"find",
"(",
"num_name",
")",
"else",
":",
"num",
"=",
"num_name",
"vg_id",
"=",
... | Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to create a new vgroup; vcreate() can also
... | [
"Open",
"an",
"existing",
"vgroup",
"given",
"its",
"name",
"or",
"its",
"reference",
"number",
"or",
"create",
"a",
"new",
"vgroup",
"returning",
"a",
"VG",
"instance",
"for",
"that",
"vgroup",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L725-L755 | train |
fhs/pyhdf | pyhdf/V.py | V.create | def create(self, name):
"""Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(nam... | python | def create(self, name):
"""Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(nam... | [
"def",
"create",
"(",
"self",
",",
"name",
")",
":",
"vg",
"=",
"self",
".",
"attach",
"(",
"-",
"1",
",",
"1",
")",
"vg",
".",
"_name",
"=",
"name",
"return",
"vg"
] | Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(name) method of the instance.
... | [
"Create",
"a",
"new",
"vgroup",
"and",
"assign",
"it",
"a",
"name",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L757-L776 | train |
fhs/pyhdf | pyhdf/V.py | V.find | def find(self, name):
"""Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: ... | python | def find(self, name):
"""Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: ... | [
"def",
"find",
"(",
"self",
",",
"name",
")",
":",
"refnum",
"=",
"_C",
".",
"Vfind",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"name",
")",
"if",
"not",
"refnum",
":",
"raise",
"HDF4Error",
"(",
"\"vgroup not found\"",
")",
"return",
"refnum"
] | Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: Vfind | [
"Find",
"a",
"vgroup",
"given",
"its",
"name",
"returning",
"its",
"reference",
"number",
"if",
"found",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L778-L798 | train |
fhs/pyhdf | pyhdf/V.py | V.findclass | def findclass(self, name):
"""Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C lib... | python | def findclass(self, name):
"""Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C lib... | [
"def",
"findclass",
"(",
"self",
",",
"name",
")",
":",
"refnum",
"=",
"_C",
".",
"Vfindclass",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"name",
")",
"if",
"not",
"refnum",
":",
"raise",
"HDF4Error",
"(",
"\"vgroup not found\"",
")",
"return",
"... | Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: Vfind | [
"Find",
"a",
"vgroup",
"given",
"its",
"class",
"name",
"returning",
"its",
"reference",
"number",
"if",
"found",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L800-L820 | train |
fhs/pyhdf | pyhdf/V.py | V.delete | def delete(self, num_name):
"""Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent... | python | def delete(self, num_name):
"""Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent... | [
"def",
"delete",
"(",
"self",
",",
"num_name",
")",
":",
"try",
":",
"vg",
"=",
"self",
".",
"attach",
"(",
"num_name",
",",
"1",
")",
"except",
"HDF4Error",
"as",
"msg",
":",
"raise",
"HDF4Error",
"(",
"\"delete: no such vgroup\"",
")",
"refnum",
"=",
... | Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent : Vdelete | [
"Delete",
"from",
"the",
"HDF",
"file",
"the",
"vgroup",
"identified",
"by",
"its",
"reference",
"number",
"or",
"its",
"name",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L822-L849 | train |
fhs/pyhdf | pyhdf/V.py | V.getid | def getid(self, ref):
"""Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
... | python | def getid(self, ref):
"""Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
... | [
"def",
"getid",
"(",
"self",
",",
"ref",
")",
":",
"num",
"=",
"_C",
".",
"Vgetid",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"ref",
")",
"_checkErr",
"(",
"'getid'",
",",
"num",
",",
"\"bad arguments or last vgroup reached\"",
")",
"return",
"num"... | Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
Returns::
refe... | [
"Obtain",
"the",
"reference",
"number",
"of",
"the",
"vgroup",
"following",
"the",
"vgroup",
"with",
"the",
"given",
"reference",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L851-L872 | train |
fhs/pyhdf | pyhdf/V.py | VG.insert | def insert(self, inst):
"""Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert
"""
... | python | def insert(self, inst):
"""Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert
"""
... | [
"def",
"insert",
"(",
"self",
",",
"inst",
")",
":",
"if",
"isinstance",
"(",
"inst",
",",
"VD",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"elif",
"isinstance",
"(",
"inst",
",",
"VG",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"else",
":",
"raise... | Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert | [
"Insert",
"a",
"vdata",
"or",
"a",
"vgroup",
"in",
"the",
"vgroup",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L994-L1017 | train |
fhs/pyhdf | pyhdf/V.py | VG.add | def add(self, tag, ref):
"""Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the additi... | python | def add(self, tag, ref):
"""Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the additi... | [
"def",
"add",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"n",
"=",
"_C",
".",
"Vaddtagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")",
"_checkErr",
"(",
"'addtagref'",
",",
"n",
",",
"'invalid arguments'",
")",
"return",
"n"
] | Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the addition
C library equivalent : V... | [
"Add",
"to",
"the",
"vgroup",
"an",
"object",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1019-L1037 | train |
fhs/pyhdf | pyhdf/V.py | VG.delete | def delete(self, tag, ref):
"""Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member wit... | python | def delete(self, tag, ref):
"""Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member wit... | [
"def",
"delete",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"_checkErr",
"(",
"'delete'",
",",
"_C",
".",
"Vdeletetagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")",
",",
"\"error deleting member\"",
")"
] | Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member with the vgroup is deleted.
The me... | [
"Delete",
"from",
"the",
"vgroup",
"the",
"member",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1039-L1059 | train |
fhs/pyhdf | pyhdf/V.py | VG.tagref | def tagref(self, index):
"""Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C libra... | python | def tagref(self, index):
"""Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C libra... | [
"def",
"tagref",
"(",
"self",
",",
"index",
")",
":",
"status",
",",
"tag",
",",
"ref",
"=",
"_C",
".",
"Vgettagref",
"(",
"self",
".",
"_id",
",",
"index",
")",
"_checkErr",
"(",
"'tagref'",
",",
"status",
",",
"\"illegal arguments\"",
")",
"return",
... | Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C library equivalent : Vgettagref | [
"Get",
"the",
"tag",
"and",
"reference",
"number",
"of",
"a",
"vgroup",
"member",
"given",
"the",
"index",
"number",
"of",
"that",
"member",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1079-L1098 | train |
fhs/pyhdf | pyhdf/V.py | VG.tagrefs | def tagrefs(self):
"""Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs
... | python | def tagrefs(self):
"""Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs
... | [
"def",
"tagrefs",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_nmembers",
"ret",
"=",
"[",
"]",
"if",
"n",
":",
"tags",
"=",
"_C",
".",
"array_int32",
"(",
"n",
")",
"refs",
"=",
"_C",
".",
"array_int32",
"(",
"n",
")",
"k",
"=",
"_C",
"."... | Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs | [
"Get",
"the",
"tags",
"and",
"reference",
"numbers",
"of",
"all",
"the",
"vgroup",
"members",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1100-L1124 | train |
fhs/pyhdf | pyhdf/V.py | VG.inqtagref | def inqtagref(self, tag, ref):
"""Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does... | python | def inqtagref(self, tag, ref):
"""Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does... | [
"def",
"inqtagref",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"return",
"_C",
".",
"Vinqtagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")"
] | Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does not belong to the vgroup,
True ... | [
"Determines",
"if",
"an",
"object",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"belongs",
"to",
"the",
"vgroup",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1126-L1143 | train |
fhs/pyhdf | pyhdf/V.py | VG.nrefs | def nrefs(self, tag):
"""Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs
... | python | def nrefs(self, tag):
"""Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs
... | [
"def",
"nrefs",
"(",
"self",
",",
"tag",
")",
":",
"n",
"=",
"_C",
".",
"Vnrefs",
"(",
"self",
".",
"_id",
",",
"tag",
")",
"_checkErr",
"(",
"'nrefs'",
",",
"n",
",",
"\"bad arguments\"",
")",
"return",
"n"
] | Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs | [
"Determine",
"the",
"number",
"of",
"tags",
"of",
"a",
"given",
"type",
"in",
"a",
"vgroup",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1145-L1161 | train |
fhs/pyhdf | pyhdf/V.py | VG.attrinfo | def attrinfo(self):
"""Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
... | python | def attrinfo(self):
"""Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
... | [
"def",
"attrinfo",
"(",
"self",
")",
":",
"dic",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"self",
".",
"_nattrs",
")",
":",
"att",
"=",
"self",
".",
"attr",
"(",
"n",
")",
"name",
",",
"type",
",",
"order",
",",
"size",
"=",
"att",
".",... | Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
- attribute data type (one of... | [
"Return",
"info",
"about",
"all",
"the",
"vgroup",
"attributes",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1218-L1245 | train |
fhs/pyhdf | pyhdf/V.py | VG.findattr | def findattr(self, name):
"""Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr
... | python | def findattr(self, name):
"""Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr
... | [
"def",
"findattr",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"att",
"=",
"self",
".",
"attr",
"(",
"name",
")",
"if",
"att",
".",
"_index",
"is",
"None",
":",
"att",
"=",
"None",
"except",
"HDF4Error",
":",
"att",
"=",
"None",
"return",
"at... | Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr | [
"Search",
"the",
"vgroup",
"for",
"a",
"given",
"attribute",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1248-L1269 | train |
fhs/pyhdf | pyhdf/SD.py | SDAttr.index | def index(self):
"""Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr
"""
self._index = _C.SDfindattr(self._obj._id, sel... | python | def index(self):
"""Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr
"""
self._index = _C.SDfindattr(self._obj._id, sel... | [
"def",
"index",
"(",
"self",
")",
":",
"self",
".",
"_index",
"=",
"_C",
".",
"SDfindattr",
"(",
"self",
".",
"_obj",
".",
"_id",
",",
"self",
".",
"_name",
")",
"_checkErr",
"(",
"'find'",
",",
"self",
".",
"_index",
",",
"'illegal attribute name'",
... | Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr | [
"Retrieve",
"the",
"attribute",
"index",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1178-L1194 | train |
fhs/pyhdf | pyhdf/SD.py | SD.end | def end(self):
"""End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library ... | python | def end(self):
"""End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library ... | [
"def",
"end",
"(",
"self",
")",
":",
"status",
"=",
"_C",
".",
"SDend",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'end'",
",",
"status",
",",
"\"cannot execute\"",
")",
"self",
".",
"_id",
"=",
"None"
] | End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library equivalent : SDend | [
"End",
"access",
"to",
"the",
"SD",
"interface",
"and",
"close",
"the",
"HDF",
"file",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1457-L1477 | train |
fhs/pyhdf | pyhdf/SD.py | SD.info | def info(self):
"""Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo
... | python | def info(self):
"""Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo
... | [
"def",
"info",
"(",
"self",
")",
":",
"status",
",",
"n_datasets",
",",
"n_file_attrs",
"=",
"_C",
".",
"SDfileinfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'info'",
",",
"status",
",",
"\"cannot execute\"",
")",
"return",
"n_datasets",
",",
"n... | Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo | [
"Retrieve",
"information",
"about",
"the",
"SD",
"interface",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1479-L1497 | train |
fhs/pyhdf | pyhdf/SD.py | SD.nametoindex | def nametoindex(self, sds_name):
"""Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex
"""
... | python | def nametoindex(self, sds_name):
"""Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex
"""
... | [
"def",
"nametoindex",
"(",
"self",
",",
"sds_name",
")",
":",
"sds_idx",
"=",
"_C",
".",
"SDnametoindex",
"(",
"self",
".",
"_id",
",",
"sds_name",
")",
"_checkErr",
"(",
"'nametoindex'",
",",
"sds_idx",
",",
"'non existent SDS'",
")",
"return",
"sds_idx"
] | Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex | [
"Return",
"the",
"index",
"number",
"of",
"a",
"dataset",
"given",
"the",
"dataset",
"name",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1499-L1515 | train |
fhs/pyhdf | pyhdf/SD.py | SD.reftoindex | def reftoindex(self, sds_ref):
"""Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex
... | python | def reftoindex(self, sds_ref):
"""Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex
... | [
"def",
"reftoindex",
"(",
"self",
",",
"sds_ref",
")",
":",
"sds_idx",
"=",
"_C",
".",
"SDreftoindex",
"(",
"self",
".",
"_id",
",",
"sds_ref",
")",
"_checkErr",
"(",
"'reftoindex'",
",",
"sds_idx",
",",
"'illegal SDS ref number'",
")",
"return",
"sds_idx"
] | Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex | [
"Returns",
"the",
"index",
"number",
"of",
"a",
"dataset",
"given",
"the",
"dataset",
"reference",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1517-L1534 | train |
fhs/pyhdf | pyhdf/SD.py | SD.setfillmode | def setfillmode(self, fill_mode):
"""Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOF... | python | def setfillmode(self, fill_mode):
"""Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOF... | [
"def",
"setfillmode",
"(",
"self",
",",
"fill_mode",
")",
":",
"if",
"not",
"fill_mode",
"in",
"[",
"SDC",
".",
"FILL",
",",
"SDC",
".",
"NOFILL",
"]",
":",
"raise",
"HDF4Error",
"(",
"\"bad fill mode\"",
")",
"old_mode",
"=",
"_C",
".",
"SDsetfillmode",... | Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOFILL do not write fill values to all datasets
... | [
"Set",
"the",
"fill",
"mode",
"for",
"all",
"the",
"datasets",
"in",
"the",
"file",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1536-L1558 | train |
fhs/pyhdf | pyhdf/SD.py | SD.select | def select(self, name_or_index):
"""Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect
"""
if isi... | python | def select(self, name_or_index):
"""Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect
"""
if isi... | [
"def",
"select",
"(",
"self",
",",
"name_or_index",
")",
":",
"if",
"isinstance",
"(",
"name_or_index",
",",
"type",
"(",
"1",
")",
")",
":",
"idx",
"=",
"name_or_index",
"else",
":",
"try",
":",
"idx",
"=",
"self",
".",
"nametoindex",
"(",
"name_or_in... | Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect | [
"Locate",
"a",
"dataset",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1603-L1626 | train |
fhs/pyhdf | pyhdf/SD.py | SD.attributes | def attributes(self, full=0):
"""Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dict... | python | def attributes(self, full=0):
"""Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dict... | [
"def",
"attributes",
"(",
"self",
",",
"full",
"=",
"0",
")",
":",
"nsds",
",",
"natts",
"=",
"self",
".",
"info",
"(",
")",
"res",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"natts",
")",
":",
"a",
"=",
"self",
".",
"attr",
"(",
"n",
"... | Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dictionnary if no global attribute defined
... | [
"Return",
"a",
"dictionnary",
"describing",
"every",
"global",
"attribute",
"attached",
"to",
"the",
"SD",
"interface",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1651-L1689 | train |
fhs/pyhdf | pyhdf/SD.py | SD.datasets | def datasets(self):
"""Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the co... | python | def datasets(self):
"""Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the co... | [
"def",
"datasets",
"(",
"self",
")",
":",
"nDs",
"=",
"self",
".",
"info",
"(",
")",
"[",
"0",
"]",
"res",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"nDs",
")",
":",
"v",
"=",
"self",
".",
"select",
"(",
"n",
")",
"vName",
",",
"vRank"... | Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the corresponding datasets.
... | [
"Return",
"a",
"dictionnary",
"describing",
"all",
"the",
"file",
"datasets",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1691-L1736 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.endaccess | def endaccess(self):
"""Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent ... | python | def endaccess(self):
"""Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent ... | [
"def",
"endaccess",
"(",
"self",
")",
":",
"status",
"=",
"_C",
".",
"SDendaccess",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'endaccess'",
",",
"status",
",",
"\"cannot execute\"",
")",
"self",
".",
"_id",
"=",
"None"
] | Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent : SDendaccess | [
"Terminates",
"access",
"to",
"the",
"SDS",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1817-L1837 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.dim | def dim(self, dim_index):
"""Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid
"""
id = _C.SDgetdimid(self._id, dim... | python | def dim(self, dim_index):
"""Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid
"""
id = _C.SDgetdimid(self._id, dim... | [
"def",
"dim",
"(",
"self",
",",
"dim_index",
")",
":",
"id",
"=",
"_C",
".",
"SDgetdimid",
"(",
"self",
".",
"_id",
",",
"dim_index",
")",
"_checkErr",
"(",
"'dim'",
",",
"id",
",",
"'invalid SDS identifier or dimension index'",
")",
"return",
"SDim",
"(",... | Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid | [
"Get",
"an",
"SDim",
"instance",
"given",
"a",
"dimension",
"index",
"number",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1840-L1851 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.get | def get(self, start=None, count=None, stride=None):
"""Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
defa... | python | def get(self, start=None, count=None, stride=None):
"""Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
defa... | [
"def",
"get",
"(",
"self",
",",
"start",
"=",
"None",
",",
"count",
"=",
"None",
",",
"stride",
"=",
"None",
")",
":",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"i... | Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
default to the current length of all dimensions
stride :... | [
"Read",
"data",
"from",
"the",
"dataset",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1853-L1920 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.set | def set(self, data, start=None, count=None, stride=None):
"""Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indic... | python | def set(self, data, start=None, count=None, stride=None):
"""Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indic... | [
"def",
"set",
"(",
"self",
",",
"data",
",",
"start",
"=",
"None",
",",
"count",
"=",
"None",
",",
"stride",
"=",
"None",
")",
":",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
... | Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indices where to start writing in the dataset;
default... | [
"Write",
"data",
"to",
"the",
"dataset",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1922-L2001 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.info | def info(self):
"""Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
data... | python | def info(self):
"""Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
data... | [
"def",
"info",
"(",
"self",
")",
":",
"buf",
"=",
"_C",
".",
"array_int32",
"(",
"_C",
".",
"H4_MAX_VAR_DIMS",
")",
"status",
",",
"sds_name",
",",
"rank",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDgetinfo",
"(",
"self",
".",
"_id",
",",
... | Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
dataset dimension; if the first... | [
"Retrieves",
"information",
"about",
"the",
"dataset",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2102-L2130 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.checkempty | def checkempty(self):
"""Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty
"""
status, emptySDS = _C.SDch... | python | def checkempty(self):
"""Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty
"""
status, emptySDS = _C.SDch... | [
"def",
"checkempty",
"(",
"self",
")",
":",
"status",
",",
"emptySDS",
"=",
"_C",
".",
"SDcheckempty",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'checkempty'",
",",
"status",
",",
"'invalid SDS identifier'",
")",
"return",
"emptySDS"
] | Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty | [
"Determine",
"whether",
"the",
"dataset",
"is",
"empty",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2132-L2148 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.ref | def ref(self):
"""Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref
"""
sds_ref = _C.SDidtoref(self._id)
_checkErr('idtore... | python | def ref(self):
"""Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref
"""
sds_ref = _C.SDidtoref(self._id)
_checkErr('idtore... | [
"def",
"ref",
"(",
"self",
")",
":",
"sds_ref",
"=",
"_C",
".",
"SDidtoref",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'idtoref'",
",",
"sds_ref",
",",
"'illegal SDS identifier'",
")",
"return",
"sds_ref"
] | Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref | [
"Get",
"the",
"reference",
"number",
"of",
"the",
"dataset",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2150-L2166 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.getcal | def getcal(self):
"""Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale... | python | def getcal(self):
"""Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale... | [
"def",
"getcal",
"(",
"self",
")",
":",
"status",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
",",
"data_type",
"=",
"_C",
".",
"SDgetcal",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'getcal'",
",",
"status",
",",
"'no calibra... | Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale_factor_err')
- off... | [
"Retrieve",
"the",
"SDS",
"calibration",
"coefficients",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2206-L2246 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.getdatastrs | def getdatastrs(self):
"""Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attri... | python | def getdatastrs(self):
"""Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attri... | [
"def",
"getdatastrs",
"(",
"self",
")",
":",
"status",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_system",
"=",
"_C",
".",
"SDgetdatastrs",
"(",
"self",
".",
"_id",
",",
"128",
")",
"_checkErr",
"(",
"'getdatastrs'",
",",
"status",
",",
"'ca... | Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attribute 'format')
- dataset... | [
"Retrieve",
"the",
"dataset",
"standard",
"string",
"attributes",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2248-L2276 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.getrange | def getrange(self):
"""Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min ... | python | def getrange(self):
"""Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min ... | [
"def",
"getrange",
"(",
"self",
")",
":",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"(",
"'getrange : invalid SDS identifier'... | Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min and max from the current datase... | [
"Retrieve",
"the",
"dataset",
"min",
"and",
"max",
"values",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2344-L2426 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setcal | def setcal(self, cal, cal_error, offset, offset_err, data_type):
"""Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offs... | python | def setcal(self, cal, cal_error, offset, offset_err, data_type):
"""Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offs... | [
"def",
"setcal",
"(",
"self",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
",",
"data_type",
")",
":",
"status",
"=",
"_C",
".",
"SDsetcal",
"(",
"self",
".",
"_id",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
"... | Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offset offset value (attribute 'add_offset')
offset_err offset e... | [
"Set",
"the",
"dataset",
"calibration",
"coefficients",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2428-L2463 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setdatastrs | def setdatastrs(self, label, unit, format, coord_sys):
"""Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
... | python | def setdatastrs(self, label, unit, format, coord_sys):
"""Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
... | [
"def",
"setdatastrs",
"(",
"self",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_sys",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdatastrs",
"(",
"self",
".",
"_id",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_sys",
")",
"_checkErr",
... | Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
coord_sys dataset coordinate system (attribute 'coordsys')
... | [
"Set",
"the",
"dataset",
"standard",
"string",
"type",
"attributes",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2465-L2490 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setfillvalue | def setfillvalue(self, fill_val):
"""Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to settin... | python | def setfillvalue(self, fill_val):
"""Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to settin... | [
"def",
"setfillvalue",
"(",
"self",
",",
"fill_val",
")",
":",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"(",
"'setfillva... | Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to setting
the following attribute::
... | [
"Set",
"the",
"dataset",
"fill",
"value",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2492-L2552 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setrange | def setrange(self, min, max):
"""Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "st... | python | def setrange(self, min, max):
"""Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "st... | [
"def",
"setrange",
"(",
"self",
",",
"min",
",",
"max",
")",
":",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"(",
"'se... | Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "standard" SDS
attributes. Calling m... | [
"Set",
"the",
"dataset",
"min",
"and",
"max",
"values",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2555-L2629 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.getcompress | def getcompress(self):
"""Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COM... | python | def getcompress(self):
"""Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COM... | [
"def",
"getcompress",
"(",
"self",
")",
":",
"status",
",",
"comp_type",
",",
"value",
",",
"v2",
",",
"v3",
",",
"v4",
",",
"v5",
"=",
"_C",
".",
"_SDgetcompress",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'getcompress'",
",",
"status",
",",
... | Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COMP_NONE 0 value no additio... | [
"Retrieves",
"info",
"about",
"dataset",
"compression",
"type",
"and",
"mode",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2631-L2677 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setcompress | def setcompress(self, comp_type, value=0, v2=0):
"""Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression t... | python | def setcompress(self, comp_type, value=0, v2=0):
"""Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression t... | [
"def",
"setcompress",
"(",
"self",
",",
"comp_type",
",",
"value",
"=",
"0",
",",
"v2",
"=",
"0",
")",
":",
"status",
"=",
"_C",
".",
"_SDsetcompress",
"(",
"self",
".",
"_id",
",",
"comp_type",
",",
"value",
",",
"v2",
")",
"_checkErr",
"(",
"'set... | Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression types
SDC.COMP_SKPHUFF Skipping-Hu... | [
"Compresses",
"the",
"dataset",
"using",
"a",
"specified",
"compression",
"method",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2679-L2718 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.setexternalfile | def setexternalfile(self, filename, offset=0):
"""Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library ... | python | def setexternalfile(self, filename, offset=0):
"""Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library ... | [
"def",
"setexternalfile",
"(",
"self",
",",
"filename",
",",
"offset",
"=",
"0",
")",
":",
"status",
"=",
"_C",
".",
"SDsetexternalfile",
"(",
"self",
".",
"_id",
",",
"filename",
",",
"offset",
")",
"_checkErr",
"(",
"'setexternalfile'",
",",
"status",
... | Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library equivalent : SDsetexternalfile | [
"Store",
"the",
"dataset",
"data",
"in",
"an",
"external",
"file",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2721-L2738 | train |
fhs/pyhdf | pyhdf/SD.py | SDS.dimensions | def dimensions(self, full=0):
"""Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension nam... | python | def dimensions(self, full=0):
"""Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension nam... | [
"def",
"dimensions",
"(",
"self",
",",
"full",
"=",
"0",
")",
":",
"nDims",
",",
"dimLen",
"=",
"self",
".",
"info",
"(",
")",
"[",
"1",
":",
"3",
"]",
"if",
"isinstance",
"(",
"dimLen",
",",
"int",
")",
":",
"dimLen",
"=",
"[",
"dimLen",
"]",
... | Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension name. If no name
has been given to... | [
"Return",
"a",
"dictionnary",
"describing",
"every",
"dataset",
"dimension",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2800-L2849 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.info | def info(self):
"""Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
... | python | def info(self):
"""Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
... | [
"def",
"info",
"(",
"self",
")",
":",
"status",
",",
"dim_name",
",",
"dim_size",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDdiminfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'info'",
",",
"status",
",",
"'cannot execute'",
")",
"ret... | Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
- dimension lengt... | [
"Return",
"info",
"about",
"the",
"dimension",
"instance",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2892-L2918 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.setname | def setname(self, dim_name):
"""Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
... | python | def setname(self, dim_name):
"""Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
... | [
"def",
"setname",
"(",
"self",
",",
"dim_name",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdimname",
"(",
"self",
".",
"_id",
",",
"dim_name",
")",
"_checkErr",
"(",
"'setname'",
",",
"status",
",",
"'cannot execute'",
")"
] | Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
None
C library equivalent :... | [
"Set",
"the",
"dimension",
"name",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2939-L2956 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.getscale | def getscale(self):
"""Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimsc... | python | def getscale(self):
"""Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimsc... | [
"def",
"getscale",
"(",
"self",
")",
":",
"status",
",",
"dim_name",
",",
"dim_size",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDdiminfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'getscale'",
",",
"status",
",",
"'cannot execute'",
")"... | Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimscale()' method was called.
... | [
"Obtain",
"the",
"scale",
"values",
"along",
"a",
"dimension",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2959-L3018 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.setscale | def setscale(self, data_type, scale):
"""Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of t... | python | def setscale(self, data_type, scale):
"""Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of t... | [
"def",
"setscale",
"(",
"self",
",",
"data_type",
",",
"scale",
")",
":",
"try",
":",
"n_values",
"=",
"len",
"(",
"scale",
")",
"except",
":",
"n_values",
"=",
"1",
"info",
"=",
"self",
".",
"_sds",
".",
"info",
"(",
")",
"if",
"info",
"[",
"1",... | Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of the dataset
along that dime... | [
"Initialize",
"the",
"scale",
"values",
"along",
"the",
"dimension",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3020-L3098 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.getstrs | def getstrs(self):
"""Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute ... | python | def getstrs(self):
"""Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute ... | [
"def",
"getstrs",
"(",
"self",
")",
":",
"status",
",",
"label",
",",
"unit",
",",
"format",
"=",
"_C",
".",
"SDgetdimstrs",
"(",
"self",
".",
"_id",
",",
"128",
")",
"_checkErr",
"(",
"'getstrs'",
",",
"status",
",",
"'cannot execute'",
")",
"return",... | Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute 'format')
An exceptio... | [
"Retrieve",
"the",
"dimension",
"standard",
"string",
"attributes",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3100-L3122 | train |
fhs/pyhdf | pyhdf/SD.py | SDim.setstrs | def setstrs(self, label, unit, format):
"""Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
... | python | def setstrs(self, label, unit, format):
"""Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
... | [
"def",
"setstrs",
"(",
"self",
",",
"label",
",",
"unit",
",",
"format",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdimstrs",
"(",
"self",
".",
"_id",
",",
"label",
",",
"unit",
",",
"format",
")",
"_checkErr",
"(",
"'setstrs'",
",",
"status",
",",
... | Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
C library equivalent: SDsetdimstrs | [
"Set",
"the",
"dimension",
"standard",
"string",
"attributes",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3124-L3141 | train |
fhs/pyhdf | pyhdf/VS.py | VS.attach | def attach(self, num_name, write=0):
"""Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
... | python | def attach(self, num_name, write=0):
"""Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
... | [
"def",
"attach",
"(",
"self",
",",
"num_name",
",",
"write",
"=",
"0",
")",
":",
"mode",
"=",
"write",
"and",
"'w'",
"or",
"'r'",
"if",
"isinstance",
"(",
"num_name",
",",
"str",
")",
":",
"num",
"=",
"self",
".",
"find",
"(",
"num_name",
")",
"e... | Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
its name. Use -1 to create a new ... | [
"Locate",
"an",
"existing",
"vdata",
"or",
"create",
"a",
"new",
"vdata",
"in",
"the",
"HDF",
"file",
"returning",
"a",
"VD",
"instance",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/VS.py#L872-L911 | train |
fhs/pyhdf | pyhdf/VS.py | VS.create | def create(self, name, fields):
"""Create a new vdata, setting its name and allocating
its fields.
Args::
name Name to assign to the vdata
fields Sequence of field definitions. Each field definition
is a sequence with the following elements in order... | python | def create(self, name, fields):
"""Create a new vdata, setting its name and allocating
its fields.
Args::
name Name to assign to the vdata
fields Sequence of field definitions. Each field definition
is a sequence with the following elements in order... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"fields",
")",
":",
"try",
":",
"vd",
"=",
"self",
".",
"attach",
"(",
"-",
"1",
",",
"1",
")",
"vd",
".",
"_name",
"=",
"name",
"allNames",
"=",
"[",
"]",
"for",
"name",
",",
"type",
",",
"orde... | Create a new vdata, setting its name and allocating
its fields.
Args::
name Name to assign to the vdata
fields Sequence of field definitions. Each field definition
is a sequence with the following elements in order:
- field name
... | [
"Create",
"a",
"new",
"vdata",
"setting",
"its",
"name",
"and",
"allocating",
"its",
"fields",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/VS.py#L913-L959 | train |
fhs/pyhdf | pyhdf/VS.py | VS.next | def next(self, vRef):
"""Get the reference number of the vdata following a given
vdata.
Args::
vRef Reference number of the vdata preceding the one
we require. Set to -1 to get the first vdata in
the HDF file. Knowing its reference number,
... | python | def next(self, vRef):
"""Get the reference number of the vdata following a given
vdata.
Args::
vRef Reference number of the vdata preceding the one
we require. Set to -1 to get the first vdata in
the HDF file. Knowing its reference number,
... | [
"def",
"next",
"(",
"self",
",",
"vRef",
")",
":",
"num",
"=",
"_C",
".",
"VSgetid",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"vRef",
")",
"_checkErr",
"(",
"'next'",
",",
"num",
",",
"'cannot get next vdata'",
")",
"return",
"num"
] | Get the reference number of the vdata following a given
vdata.
Args::
vRef Reference number of the vdata preceding the one
we require. Set to -1 to get the first vdata in
the HDF file. Knowing its reference number,
the vdata can then be op... | [
"Get",
"the",
"reference",
"number",
"of",
"the",
"vdata",
"following",
"a",
"given",
"vdata",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/VS.py#L984-L1008 | train |
fhs/pyhdf | pyhdf/VS.py | VS.vdatainfo | def vdatainfo(self, listAttr=0):
"""Return info about all the file vdatas.
Args::
listAttr Set to 0 to ignore vdatas used to store attribute
values, 1 to list them (see the VD._isattr readonly
attribute)
Returns::
List of vdata ... | python | def vdatainfo(self, listAttr=0):
"""Return info about all the file vdatas.
Args::
listAttr Set to 0 to ignore vdatas used to store attribute
values, 1 to list them (see the VD._isattr readonly
attribute)
Returns::
List of vdata ... | [
"def",
"vdatainfo",
"(",
"self",
",",
"listAttr",
"=",
"0",
")",
":",
"lst",
"=",
"[",
"]",
"ref",
"=",
"-",
"1",
"while",
"True",
":",
"try",
":",
"nxtRef",
"=",
"self",
".",
"next",
"(",
"ref",
")",
"except",
"HDF4Error",
":",
"break",
"ref",
... | Return info about all the file vdatas.
Args::
listAttr Set to 0 to ignore vdatas used to store attribute
values, 1 to list them (see the VD._isattr readonly
attribute)
Returns::
List of vdata descriptions. Each vdata is described as
... | [
"Return",
"info",
"about",
"all",
"the",
"file",
"vdatas",
"."
] | dbdc1810a74a38df50dcad81fe903e239d2b388d | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/VS.py#L1010-L1060 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.