INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
LIST command. | def list(self, keyword=None, arg=None):
"""LIST command.
A wrapper for all of the other list commands. The output of this command
depends on the keyword specified. The output format for each keyword can
be found in the list function that corresponds to the keyword.
Args:
... |
GROUP command. | def group(self, name):
"""GROUP command.
"""
args = name
code, message = self.command("GROUP", args)
if code != 211:
raise NNTPReplyError(code, message)
parts = message.split(None, 4)
try:
total = int(parts[0])
first = int(par... |
NEXT command. | def next(self):
"""NEXT command.
"""
code, message = self.command("NEXT")
if code != 223:
raise NNTPReplyError(code, message)
parts = message.split(None, 3)
try:
article = int(parts[0])
ident = parts[1]
except (IndexError, Valu... |
ARTICLE command. | def article(self, msgid_article=None, decode=None):
"""ARTICLE command.
"""
args = None
if msgid_article is not None:
args = utils.unparse_msgid_article(msgid_article)
code, message = self.command("ARTICLE", args)
if code != 220:
raise NNTPReplyEr... |
HEAD command. | def head(self, msgid_article=None):
"""HEAD command.
"""
args = None
if msgid_article is not None:
args = utils.unparse_msgid_article(msgid_article)
code, message = self.command("HEAD", args)
if code != 221:
raise NNTPReplyError(code, message)
... |
BODY command. | def body(self, msgid_article=None, decode=False):
"""BODY command.
"""
args = None
if msgid_article is not None:
args = utils.unparse_msgid_article(msgid_article)
code, message = self.command("BODY", args)
if code != 222:
raise NNTPReplyError(code... |
XGTITLE command. | def xgtitle(self, pattern=None):
"""XGTITLE command.
"""
args = pattern
code, message = self.command("XGTITLE", args)
if code != 282:
raise NNTPReplyError(code, message)
return self.info(code, message) |
XHDR command. | def xhdr(self, header, msgid_range=None):
"""XHDR command.
"""
args = header
if range is not None:
args += " " + utils.unparse_msgid_range(msgid_range)
code, message = self.command("XHDR", args)
if code != 221:
raise NNTPReplyError(code, message)
... |
XZHDR command. | def xzhdr(self, header, msgid_range=None):
"""XZHDR command.
Args:
msgid_range: A message-id as a string, or an article number as an
integer, or a tuple of specifying a range of article numbers in
the form (first, [last]) - if last is omitted then all article... |
Generator for the XOVER command. | def xover_gen(self, range=None):
"""Generator for the XOVER command.
The XOVER command returns information from the overview database for
the article(s) specified.
<http://tools.ietf.org/html/rfc2980#section-2.8>
Args:
range: An article number as an integer, or a t... |
Generator for the XPAT command. | def xpat_gen(self, header, msgid_range, *pattern):
"""Generator for the XPAT command.
"""
args = " ".join(
[header, utils.unparse_msgid_range(msgid_range)] + list(pattern)
)
code, message = self.command("XPAT", args)
if code != 221:
raise NNTPRepl... |
XPAT command. | def xpat(self, header, id_range, *pattern):
"""XPAT command.
"""
return [x for x in self.xpat_gen(header, id_range, *pattern)] |
XFEATURE COMPRESS GZIP command. | def xfeature_compress_gzip(self, terminator=False):
"""XFEATURE COMPRESS GZIP command.
"""
args = "TERMINATOR" if terminator else None
code, message = self.command("XFEATURE COMPRESS GZIP", args)
if code != 290:
raise NNTPReplyError(code, message)
return Tru... |
POST command. | def post(self, headers={}, body=""):
"""POST command.
Args:
headers: A dictionary of headers.
body: A string or file like object containing the post content.
Raises:
NNTPDataError: If binary characters are detected in the message
body.
... |
assumes that classes that inherit list tuple or dict have a constructor that is compatible with those base classes. If you are using classes that don t satisfy this requirement you can subclass them and add a lower () method for the class | def _lower(v):
"""assumes that classes that inherit list, tuple or dict have a constructor
that is compatible with those base classes. If you are using classes that
don't satisfy this requirement you can subclass them and add a lower()
method for the class"""
if hasattr(v, "lower"):
return v... |
The standard quadratic limb darkening law.: param ndarray r: The radius vector: param limbdark: A: py: class: pysyzygy. transit. LIMBDARK instance containing the limb darkening law information: returns: The stellar intensity as a function of r | def I(r, limbdark):
'''
The standard quadratic limb darkening law.
:param ndarray r: The radius vector
:param limbdark: A :py:class:`pysyzygy.transit.LIMBDARK` instance containing
the limb darkening law information
:returns: The stellar intensity as a function of `r`
'''
if... |
Plots a light curve described by kwargs: param bool compact: Display the compact version of the plot? Default False: param bool ldplot: Displat the limb darkening inset? Default True: param str plottitle: The title of the plot. Default: param float xlim: The half - width of the orbit plot in stellar radii. Default is t... | def PlotTransit(compact = False, ldplot = True, plottitle = "",
xlim = None, binned = True, **kwargs):
'''
Plots a light curve described by `kwargs`
:param bool compact: Display the compact version of the plot? Default `False`
:param bool ldplot: Displat the limb darkening inset? Default `Tr... |
Parse timezone to offset in seconds. | def _offset(value):
"""Parse timezone to offset in seconds.
Args:
value: A timezone in the '+0000' format. An integer would also work.
Returns:
The timezone offset from GMT in seconds as an integer.
"""
o = int(value)
if o == 0:
return 0
a = abs(o)
s = a*36+(a%1... |
Convert timestamp string to time in seconds since epoch. | def timestamp_d_b_Y_H_M_S(value):
"""Convert timestamp string to time in seconds since epoch.
Timestamps strings like '18 Jun 2013 12:00:00 GMT' are able to be converted
by this function.
Args:
value: A timestamp string in the format '%d %b %Y %H:%M:%S GMT'.
Returns:
The time in s... |
Convert timestamp string to a datetime object. | def datetimeobj_d_b_Y_H_M_S(value):
"""Convert timestamp string to a datetime object.
Timestamps strings like '18 Jun 2013 12:00:00 GMT' are able to be converted
by this function.
Args:
value: A timestamp string in the format '%d %b %Y %H:%M:%S GMT'.
Returns:
A datetime object.
... |
Convert timestamp string to time in seconds since epoch. | def timestamp_a__d_b_Y_H_M_S_z(value):
"""Convert timestamp string to time in seconds since epoch.
Timestamps strings like 'Tue, 18 Jun 2013 22:00:00 +1000' are able to be
converted by this function.
Args:
value: A timestamp string in the format '%a, %d %b %Y %H:%M:%S %z'.
Returns:
... |
Convert timestamp string to a datetime object. | def datetimeobj_a__d_b_Y_H_M_S_z(value):
"""Convert timestamp string to a datetime object.
Timestamps strings like 'Tue, 18 Jun 2013 22:00:00 +1000' are able to be
converted by this function.
Args:
value: A timestamp string in the format '%a, %d %b %Y %H:%M:%S %z'.
Returns:
A date... |
Convert timestamp string to time in seconds since epoch. | def timestamp_YmdHMS(value):
"""Convert timestamp string to time in seconds since epoch.
Timestamps strings like '20130618120000' are able to be converted by this
function.
Args:
value: A timestamp string in the format '%Y%m%d%H%M%S'.
Returns:
The time in seconds since epoch as an... |
Convert timestamp string to a datetime object. | def datetimeobj_YmdHMS(value):
"""Convert timestamp string to a datetime object.
Timestamps strings like '20130618120000' are able to be converted by this
function.
Args:
value: A timestamp string in the format '%Y%m%d%H%M%S'.
Returns:
A datetime object.
Raises:
Value... |
Convert timestamp string to a datetime object. | def datetimeobj_epoch(value):
"""Convert timestamp string to a datetime object.
Timestamps strings like '1383470155' are able to be converted by this
function.
Args:
value: A timestamp string as seconds since epoch.
Returns:
A datetime object.
Raises:
ValueError: If t... |
Convert timestamp string to time in seconds since epoch. | def timestamp_fmt(value, fmt):
"""Convert timestamp string to time in seconds since epoch.
Wraps the datetime.datetime.strptime(). This is slow use the other
timestamp_*() functions if possible.
Args:
value: A timestamp string.
fmt: A timestamp format string.
Returns:
The ... |
Convert timestamp string to time in seconds since epoch. | def timestamp_any(value):
"""Convert timestamp string to time in seconds since epoch.
Most timestamps strings are supported in fact this wraps the
dateutil.parser.parse() method. This is SLOW use the other timestamp_*()
functions if possible.
Args:
value: A timestamp string.
Returns:
... |
Parse a datetime to a unix timestamp. | def timestamp(value, fmt=None):
"""Parse a datetime to a unix timestamp.
Uses fast custom parsing for common datetime formats or the slow dateutil
parser for other formats. This is a trade off between ease of use and speed
and is very useful for fast parsing of timestamp strings whose format may
st... |
Parse a datetime to a datetime object. | def datetimeobj(value, fmt=None):
"""Parse a datetime to a datetime object.
Uses fast custom parsing for common datetime formats or the slow dateutil
parser for other formats. This is a trade off between ease of use and speed
and is very useful for fast parsing of timestamp strings whose format may
... |
Fix the alert config. args () dict for the correct key name | def _fix_alert_config_dict(alert_config):
"""
Fix the alert config .args() dict for the correct key name
"""
data = alert_config.args()
data['params_set'] = data.get('args')
del data['args']
return data |
returns the payload the login page expects: rtype: dict | def _get_login_payload(self, username, password):
"""
returns the payload the login page expects
:rtype: dict
"""
payload = {
'csrfmiddlewaretoken': self._get_csrf_token(),
'ajax': '1',
'next': '/app/',
'username': username,
... |
Convenience method for posting | def _api_post(self, url, **kwargs):
"""
Convenience method for posting
"""
response = self.session.post(
url=url,
headers=self._get_api_headers(),
**kwargs
)
if not response.ok:
raise ServerException(
'{0}: {... |
Convenience method for deleting | def _api_delete(self, url, **kwargs):
"""
Convenience method for deleting
"""
response = self.session.delete(
url=url,
headers=self._get_api_headers(),
**kwargs
)
if not response.ok:
raise ServerException(
'{... |
Convenience method for getting | def _api_get(self, url, **kwargs):
"""
Convenience method for getting
"""
response = self.session.get(
url=url,
headers=self._get_api_headers(),
**kwargs
)
if not response.ok:
raise ServerException(
'{0}: {1}... |
. _login () makes three requests: | def _login(self, username, password):
"""
._login() makes three requests:
* One to the /login/ page to get a CSRF cookie
* One to /login/ajax/ to get a logged-in session cookie
* One to /app/ to get the beginning of the account id
:param username: A valid us... |
List all scheduled_queries | def list_scheduled_queries(self):
"""
List all scheduled_queries
:return: A list of all scheduled query dicts
:rtype: list of dict
:raises: This will raise a
:class:`ServerException<logentries_api.exceptions.ServerException>`
if there is an error from Lo... |
List all tags for the account. | def list_tags(self):
"""
List all tags for the account.
The response differs from ``Hooks().list()``, in that tag dicts for
anomaly alerts include a 'scheduled_query_id' key with the value being
the UUID for the associated scheduled query
:return: A list of all tag dict... |
Get alert by name or id | def get(self, name_or_id):
"""
Get alert by name or id
:param name_or_id: The alert's name or id
:type name_or_id: str
:return: A list of matching tags. An empty list is returned if there are
not any matches
:rtype: list of dict
:raises: This will r... |
Create an inactivity alert | def create(self, name, patterns, logs, trigger_config, alert_reports):
"""
Create an inactivity alert
:param name: A name for the inactivity alert
:type name: str
:param patterns: A list of regexes to match
:type patterns: list of str
:param logs: A list of log... |
Delete the specified InactivityAlert | def delete(self, tag_id):
"""
Delete the specified InactivityAlert
:param tag_id: The tag ID to delete
:type tag_id: str
:raises: This will raise a
:class:`ServerException <logentries_api.exceptions.ServerException>`
if there is an error from Logentries
... |
Create the scheduled query | def _create_scheduled_query(self, query, change, scope_unit, scope_count):
"""
Create the scheduled query
"""
query_data = {
'scheduled_query': {
'name': 'ForAnomalyReport',
'query': query,
'threshold_type': '%',
... |
Create an anomaly alert. This call makes 2 requests one to create a scheduled_query and another to create the alert. | def create(self,
name,
query,
scope_count,
scope_unit,
increase_positive,
percentage_change,
trigger_config,
logs,
alert_reports):
"""
Create an anomaly alert. This call... |
Delete a specified anomaly alert tag and its scheduled query | def delete(self, tag_id):
"""
Delete a specified anomaly alert tag and its scheduled query
This method makes 3 requests:
* One to get the associated scheduled_query_id
* One to delete the alert
* One to delete get scheduled query
:param tag_id: The ... |
Unparse a range argument. | def unparse_range(obj):
"""Unparse a range argument.
Args:
obj: An article range. There are a number of valid formats; an integer
specifying a single article or a tuple specifying an article range.
If the range doesn't give a start article then all articles up to
the... |
Parse a newsgroup info line to python types. | def parse_newsgroup(line):
"""Parse a newsgroup info line to python types.
Args:
line: An info response line containing newsgroup info.
Returns:
A tuple of group name, low-water as integer, high-water as integer and
posting status.
Raises:
ValueError: If the newsgroup ... |
Parse a header line. | def parse_header(line):
"""Parse a header line.
Args:
line: A header line as a string.
Returns:
None if end of headers is found. A string giving the continuation line
if a continuation is found. A tuple of name, value when a header line is
found.
Raises:
ValueE... |
Parse a string a iterable object ( including file like objects ) to a python dictionary. | def parse_headers(obj):
"""Parse a string a iterable object (including file like objects) to a
python dictionary.
Args:
obj: An iterable object including file-like objects.
Returns:
An dictionary of headers. If a header is repeated then the last value
for that header is given.
... |
Parse a dictionary of headers to a string. | def unparse_headers(hdrs):
"""Parse a dictionary of headers to a string.
Args:
hdrs: A dictionary of headers.
Returns:
The headers as a string that can be used in an NNTP POST.
"""
return "".join([unparse_header(n, v) for n, v in hdrs.items()]) + "\r\n" |
Handles the POST request sent by Boundary Url Action | def do_POST(self):
"""
Handles the POST request sent by Boundary Url Action
"""
self.send_response(urllib2.httplib.OK)
self.end_headers()
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
print("Client: {0}".format... |
Run the tests that are loaded by each of the strings provided. | def run(tests=(), reporter=None, stop_after=None):
"""
Run the tests that are loaded by each of the strings provided.
Arguments:
tests (iterable):
the collection of tests (specified as `str` s) to run
reporter (Reporter):
a `Reporter` to use for the run. If unpro... |
Return a docstring from a list of defaults. | def defaults_docstring(defaults, header=None, indent=None, footer=None):
"""Return a docstring from a list of defaults.
"""
if indent is None:
indent = ''
if header is None:
header = ''
if footer is None:
footer = ''
width = 60
#hbar = indent + width * '=' + '\n' # ... |
Decorator to append default kwargs to a function. | def defaults_decorator(defaults):
"""Decorator to append default kwargs to a function.
"""
def decorator(func):
"""Function that appends default kwargs to a function.
"""
kwargs = dict(header='Keyword arguments\n-----------------\n',
indent=' ',
... |
Load kwargs key value pairs into __dict__ | def _load(self, **kwargs):
"""Load kwargs key,value pairs into __dict__
"""
defaults = dict([(d[0], d[1]) for d in self.defaults])
# Require kwargs are in defaults
for k in kwargs:
if k not in defaults:
msg = "Unrecognized attribute of %s: %s" % (
... |
Add the default values to the class docstring | def defaults_docstring(cls, header=None, indent=None, footer=None):
"""Add the default values to the class docstring"""
return defaults_docstring(cls.defaults, header=header,
indent=indent, footer=footer) |
Set the value | def set_value(self, value):
"""Set the value
This invokes hooks for type-checking and bounds-checking that
may be implemented by sub-classes.
"""
self.check_bounds(value)
self.check_type(value)
self.__value__ = value |
Hook for type - checking invoked during assignment. | def check_type(self, value):
"""Hook for type-checking, invoked during assignment.
raises TypeError if neither value nor self.dtype are None and they
do not match.
will not raise an exception if either value or self.dtype is None
"""
if self.__dict__['dtype'] is None:
... |
Return the current value. | def value(self):
"""Return the current value.
This first checks if the value is cached (i.e., if
`self.__value__` is not None)
If it is not cached then it invokes the `loader` function to
compute the value, and caches the computed value
"""
if self.__value__ i... |
Hook for type - checking invoked during assignment. Allows size 1 numpy arrays and lists but raises TypeError if value can not be cast to a scalar. | def check_type(self, value):
"""Hook for type-checking, invoked during assignment. Allows size 1
numpy arrays and lists, but raises TypeError if value can not
be cast to a scalar.
"""
try:
scalar = asscalar(value)
except ValueError as e:
raise Typ... |
Return the symmertic error | def symmetric_error(self):
"""Return the symmertic error
Similar to above, but zero implies no error estimate,
and otherwise this will either be the symmetric error,
or the average of the low,high asymmetric errors.
"""
# ADW: Should this be `np.nan`?
if self.__e... |
Set free/ fixed status | def set_free(self, free):
"""Set free/fixed status """
if free is None:
self.__free__ = False
return
self.__free__ = bool(free) |
Set parameter error estimate | def set_errors(self, errors):
"""Set parameter error estimate """
if errors is None:
self.__errors__ = None
return
self.__errors__ = [asscalar(e) for e in errors] |
Set the value bounds free errors based on corresponding kwargs | def set(self, **kwargs):
"""Set the value,bounds,free,errors based on corresponding kwargs
The invokes hooks for type-checking and bounds-checking that
may be implemented by sub-classes.
"""
# Probably want to reset bounds if set fails
if 'bounds' in kwargs:
... |
Load the metrics file from the given path | def load_and_parse(self):
"""
Load the metrics file from the given path
"""
f = open(self.file_path, "r")
metrics_json = f.read()
self.metrics = json.loads(metrics_json) |
1 ) Get command line arguments 2 ) Read the JSON file 3 ) Parse into a dictionary 4 ) Create or update definitions using API call | def import_metrics(self):
"""
1) Get command line arguments
2) Read the JSON file
3) Parse into a dictionary
4) Create or update definitions using API call
"""
self.v2Metrics = self.metricDefinitionV2(self.metrics)
if self.v2Metrics:
metrics =... |
Create an instance using the result of the timezone () call in pytz. | def create_from_pytz(cls, tz_info):
"""Create an instance using the result of the timezone() call in
"pytz".
"""
zone_name = tz_info.zone
utc_transition_times_list_raw = getattr(tz_info,
'_utc_transition_times',
... |
Extract required fields from an array | def extract_dictionary(self, metrics):
"""
Extract required fields from an array
"""
new_metrics = {}
for m in metrics:
metric = self.extract_fields(m)
new_metrics[m['name']] = metric
return new_metrics |
Apply the criteria to filter out on the metrics required | def filter(self):
"""
Apply the criteria to filter out on the metrics required
"""
if self.filter_expression is not None:
new_metrics = []
metrics = self.metrics['result']
for m in metrics:
if self.filter_expression.search(m['name']):
... |
Extracts the specific arguments of this CLI | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.hostGroupId is not None:
self.hostGroupId = self.args.hostGroupId
self.path = "v1/hostgroup/{0}".format(str(self.hostGroupId)) |
Extracts the specific arguments of this CLI | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.tenant_id is not None:
self._tenant_id = self.args.tenant_id
if self.args.fingerprint_fields is not None:
self._fingerprint_field... |
Make a call to the meter via JSON RPC | def _call_api(self):
"""
Make a call to the meter via JSON RPC
"""
# Allocate a socket and connect to the meter
sockobj = socket(AF_INET, SOCK_STREAM)
sockobj.connect((self.rpc_host, self.rpc_port))
self.get_json()
message = [self.rpc_message.encode('utf-... |
Extracts the specific arguments of this CLI | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
HostgroupModify.get_arguments(self)
if self.args.host_group_id is not None:
self.host_group_id = self.args.host_group_id
self.path = "v1/hostgroup/" + str(self.host_group_id) |
identifier = alpha_character | _. { alpha_character | _ | digit } ; | def identifier(self, text):
"""identifier = alpha_character | "_" . {alpha_character | "_" | digit} ;"""
self._attempting(text)
return concatenation([
alternation([
self.alpha_character,
"_"
]),
zero_or_more(
alternation([
self.alpha_character,
"... |
expression = number op_mult expression | expression_terminal op_mult number [ operator expression ] | expression_terminal op_add [ operator expression ] | expression_terminal [ operator expression ] ; | def expression(self, text):
"""expression = number , op_mult , expression
| expression_terminal , op_mult , number , [operator , expression]
| expression_terminal , op_add , [operator , expression]
| expression_terminal , [operator , expression] ;
"""
se... |
expression_terminal = identifier | terminal | option_group | repetition_group | grouping_group | special_handling ; | def expression_terminal(self, text):
"""expression_terminal = identifier
| terminal
| option_group
| repetition_group
| grouping_group
| special_handling ;
"""
self._attempt... |
option_group = [ expression ] ; | def option_group(self, text):
"""option_group = "[" , expression , "]" ;"""
self._attempting(text)
return concatenation([
"[",
self.expression,
"]"
], ignore_whitespace=True)(text).retyped(TokenType.option_group) |
terminal =. ( printable - ) +. |. ( printable - ) +. ; | def terminal(self, text):
"""terminal = '"' . (printable - '"') + . '"'
| "'" . (printable - "'") + . "'" ;
"""
self._attempting(text)
return alternation([
concatenation([
'"',
one_or_more(
exclusion(self.printable, '"')
),
'"'
], ign... |
operator = | |. | | - ; | def operator(self, text):
"""operator = "|" | "." | "," | "-";"""
self._attempting(text)
return alternation([
"|",
".",
",",
"-"
])(text).retyped(TokenType.operator) |
op_mult = * ; | def op_mult(self, text):
"""op_mult = "*" ;"""
self._attempting(text)
return terminal("*")(text).retyped(TokenType.op_mult) |
op_add = + ; | def op_add(self, text):
"""op_add = "+" ;"""
self._attempting(text)
return terminal("+")(text).retyped(TokenType.op_add) |
Set the value ( and bounds ) of the named parameter. | def setp(self, name, clear_derived=True, value=None,
bounds=None, free=None, errors=None):
"""
Set the value (and bounds) of the named parameter.
Parameters
----------
name : str
The parameter name.
clear_derived : bool
Flag to clear... |
Set a group of attributes ( parameters and members ). Calls setp directly so kwargs can include more than just the parameter value ( e. g. bounds free etc. ). | def set_attributes(self, **kwargs):
"""
Set a group of attributes (parameters and members). Calls
`setp` directly, so kwargs can include more than just the
parameter value (e.g., bounds, free, etc.).
"""
self.clear_derived()
kwargs = dict(kwargs)
for name... |
Loop through the list of Properties extract the derived and required properties and do the appropriate book - keeping | def _init_properties(self):
""" Loop through the list of Properties,
extract the derived and required properties and do the
appropriate book-keeping
"""
self._missing = {}
for k, p in self.params.items():
if p.required:
self._missing[k] = p
... |
Return a list of Parameter objects | def get_params(self, pnames=None):
""" Return a list of Parameter objects
Parameters
----------
pname : list or None
If a list get the Parameter objects with those names
If none, get all the Parameter objects
Returns
-------
params : lis... |
Return an array with the parameter values | def param_values(self, pnames=None):
""" Return an array with the parameter values
Parameters
----------
pname : list or None
If a list, get the values of the `Parameter` objects with those names
If none, get all values of all the `Parameter` objects
Ret... |
Return an array with the parameter errors | def param_errors(self, pnames=None):
""" Return an array with the parameter errors
Parameters
----------
pname : list of string or none
If a list of strings, get the Parameter objects with those names
If none, get all the Parameter objects
Returns
... |
Reset the value of all Derived properties to None | def clear_derived(self):
""" Reset the value of all Derived properties to None
This is called by setp (and by extension __setattr__)
"""
for p in self.params.values():
if isinstance(p, Derived):
p.clear_value() |
Extracts the specific arguments of this CLI | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
ApiCli.get_arguments(self)
if self.args.pluginName is not None:
self.pluginName = self.args.pluginName
self.path = "v1/plugins/{0}/components".format(self.pluginName) |
Before assigning the value validate that is in one of the HTTP methods we implement | def method(self, value):
"""
Before assigning the value validate that is in one of the
HTTP methods we implement
"""
keys = self._methods.keys()
if value not in keys:
raise AttributeError("Method value not in " + str(keys))
else:
self._meth... |
Gets the configuration stored in environment variables | def _get_environment(self):
"""
Gets the configuration stored in environment variables
"""
if 'TSP_EMAIL' in os.environ:
self._email = os.environ['TSP_EMAIL']
if 'TSP_API_TOKEN' in os.environ:
self._api_token = os.environ['TSP_API_TOKEN']
if 'TSP_A... |
Encode URL parameters | def _get_url_parameters(self):
"""
Encode URL parameters
"""
url_parameters = ''
if self._url_parameters is not None:
url_parameters = '?' + urllib.urlencode(self._url_parameters)
return url_parameters |
Returns a metric definition identified by name: param enabled: Return only enabled metrics: param custom: Return only custom metrics: return Metrics: | def metric_get(self, enabled=False, custom=False):
"""
Returns a metric definition identified by name
:param enabled: Return only enabled metrics
:param custom: Return only custom metrics
:return Metrics:
"""
self.path = 'v1/metrics?enabled={0}&{1}'.format(enabled... |
HTTP Get Request | def _do_get(self):
"""
HTTP Get Request
"""
return requests.get(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token)) |
HTTP Delete Request | def _do_delete(self):
"""
HTTP Delete Request
"""
return requests.delete(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token)) |
HTTP Post Request | def _do_post(self):
"""
HTTP Post Request
"""
return requests.post(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token)) |
HTTP Put Request | def _do_put(self):
"""
HTTP Put Request
"""
return requests.put(self._url, data=self._data, headers=self._headers, auth=(self._email, self._api_token)) |
Make an API call to get the metric definition | def _call_api(self):
"""
Make an API call to get the metric definition
"""
self._url = self.form_url()
if self._headers is not None:
logging.debug(self._headers)
if self._data is not None:
logging.debug(self._data)
if len(self._get_url_par... |
Extracts the specific arguments of this CLI | def get_arguments(self):
"""
Extracts the specific arguments of this CLI
"""
# ApiCli.get_arguments(self)
if self.args.file_name is not None:
self.file_name = self.args.file_name |
Run the steps to execute the CLI | def execute(self):
"""
Run the steps to execute the CLI
"""
# self._get_environment()
self.add_arguments()
self._parse_args()
self.get_arguments()
if self._validate_arguments():
self._plot_data()
else:
print(self._message) |
Check scene name and whether remote file exists. Raises WrongSceneNameError if the scene name is wrong. | def validate_sceneInfo(self):
"""Check scene name and whether remote file exists. Raises
WrongSceneNameError if the scene name is wrong.
"""
if self.sceneInfo.prefix not in self.__satellitesMap:
raise WrongSceneNameError('USGS Downloader: Prefix of %s (%s) is invalid'
... |
Gets satellite id | def verify_type_product(self, satellite):
"""Gets satellite id """
if satellite == 'L5':
id_satellite = '3119'
stations = ['GLC', 'ASA', 'KIR', 'MOR', 'KHC', 'PAC', 'KIS', 'CHM', 'LGS', 'MGR', 'COA', 'MPS']
elif satellite == 'L7':
id_satellite = '3373'
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.