_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q246500 | BaseFormat.display | train | def display(self):
""" Write results to an output stream """
total = 0
count = 0
for i, result in enumerate(self._results):
if total == 0:
self.pre_write()
self.write(result)
count += 1
total += 1
if (
... | python | {
"resource": ""
} |
q246501 | BaseFormat.format_field | train | def format_field(self, field):
""" Format a single Dynamo value """
if field is None:
return "NULL"
elif isinstance(field, TypeError):
return "TypeError"
elif isinstance(field, Decimal):
if field % 1 == 0:
return str(int(field))
... | python | {
"resource": ""
} |
q246502 | ColumnFormat._write_header | train | def _write_header(self):
""" Write out the table header """
self._ostream.write(len(self._header) * "-" + "\n")
self._ostream.write(self._header)
| python | {
"resource": ""
} |
q246503 | SmartBuffer.write | train | def write(self, arg):
""" Write a string or bytes object to the buffer """
if isinstance(arg, str):
| python | {
"resource": ""
} |
q246504 | prompt | train | def prompt(msg, default=NO_DEFAULT, validate=None):
""" Prompt user for input """
while True:
response = input(msg + " ").strip()
if not response:
if default is NO_DEFAULT:
| python | {
"resource": ""
} |
q246505 | promptyn | train | def promptyn(msg, default=None):
""" Display a blocking prompt until the user confirms """
while True:
yes = "Y" if default else "y"
if default or default is None:
no = "n"
| python | {
"resource": ""
} |
q246506 | repl_command | train | def repl_command(fxn):
"""
Decorator for cmd methods
Parses arguments from the arg string and passes them to the method as *args
and **kwargs.
"""
@functools.wraps(fxn)
def wrapper(self, arglist):
"""Wraps the command method"""
args = []
kwargs = {}
if argl... | python | {
"resource": ""
} |
q246507 | get_enum_key | train | def get_enum_key(key, choices):
""" Get an enum by prefix or equality """
if key in choices:
return key
keys = | python | {
"resource": ""
} |
q246508 | DQLClient.initialize | train | def initialize(
self, region="us-west-1", host=None, port=8000, config_dir=None, session=None
):
""" Set up the repl for execution. """
try:
import readline
import rlcompleter
except ImportError:
# Windows doesn't have readline, so gracefully ignor... | python | {
"resource": ""
} |
q246509 | DQLClient.update_prompt | train | def update_prompt(self):
""" Update the prompt """
prefix = ""
if self._local_endpoint is not None:
prefix += "(%s:%d) " % self._local_endpoint
prefix += self.engine.region
| python | {
"resource": ""
} |
q246510 | DQLClient.save_config | train | def save_config(self):
""" Save the conf file """
if not os.path.exists(self._conf_dir):
os.makedirs(self._conf_dir)
| python | {
"resource": ""
} |
q246511 | DQLClient.load_config | train | def load_config(self):
""" Load your configuration settings from a file """
conf_file = os.path.join(self._conf_dir, "dql.json")
if not os.path.exists(conf_file):
| python | {
"resource": ""
} |
q246512 | DQLClient.do_opt | train | def do_opt(self, *args, **kwargs):
""" Get and set options """
args = list(args)
if not args:
largest = 0
keys = [key for key in self.conf if not key.startswith("_")]
for key in keys:
largest = max(largest, len(key))
for key in keys... | python | {
"resource": ""
} |
q246513 | DQLClient.getopt_default | train | def getopt_default(self, option):
""" Default method to get an option """
if option not in self.conf:
print("Unrecognized option %r" | python | {
"resource": ""
} |
q246514 | DQLClient.complete_opt | train | def complete_opt(self, text, line, begidx, endidx):
""" Autocomplete for options """
tokens = line.split()
if len(tokens) == 1:
if text:
return
else:
option = ""
else:
option = tokens[1]
if len(tokens) == 1 or (l... | python | {
"resource": ""
} |
q246515 | DQLClient.opt_pagesize | train | def opt_pagesize(self, pagesize):
""" Get or set the page size of the query output """
if pagesize != "auto":
| python | {
"resource": ""
} |
q246516 | DQLClient._print_enum_opt | train | def _print_enum_opt(self, option, choices):
""" Helper for enum options """
for key in choices: | python | {
"resource": ""
} |
q246517 | DQLClient.opt_display | train | def opt_display(self, display):
""" Set value for display option """
key = get_enum_key(display, DISPLAYS)
if key is not None:
self.conf["display"] = key
self.display = DISPLAYS[key]
| python | {
"resource": ""
} |
q246518 | DQLClient.complete_opt_display | train | def complete_opt_display(self, text, *_):
""" Autocomplete for display option """
| python | {
"resource": ""
} |
q246519 | DQLClient.opt_format | train | def opt_format(self, fmt):
""" Set value for format option """
key = get_enum_key(fmt, FORMATTERS)
if key is not None:
self.conf["format"] = key
| python | {
"resource": ""
} |
q246520 | DQLClient.complete_opt_format | train | def complete_opt_format(self, text, *_):
""" Autocomplete for | python | {
"resource": ""
} |
q246521 | DQLClient.opt_allow_select_scan | train | def opt_allow_select_scan(self, allow):
""" Set option allow_select_scan """
allow = | python | {
"resource": ""
} |
q246522 | DQLClient.complete_opt_allow_select_scan | train | def complete_opt_allow_select_scan(self, text, *_):
""" Autocomplete for allow_select_scan | python | {
"resource": ""
} |
q246523 | DQLClient.do_watch | train | def do_watch(self, *args):
""" Watch Dynamo tables consumed capacity """
tables = []
if not self.engine.cached_descriptions:
self.engine.describe_all()
all_tables = list(self.engine.cached_descriptions)
for arg in args:
candidates = set((t for t in all_tab... | python | {
"resource": ""
} |
q246524 | DQLClient.complete_watch | train | def complete_watch(self, text, *_):
""" Autocomplete for watch """
return [t + " " for t in | python | {
"resource": ""
} |
q246525 | DQLClient.do_file | train | def do_file(self, filename):
""" Read and execute a .dql file """
| python | {
"resource": ""
} |
q246526 | DQLClient.complete_file | train | def complete_file(self, text, line, *_):
""" Autocomplete DQL file lookup """
leading = line[len("file ") :]
curpath = os.path.join(os.path.curdir, leading)
def isdql(parent, filename):
""" Check if a file is .dql or a dir """
return not filename.startswith(".") ... | python | {
"resource": ""
} |
q246527 | DQLClient.do_ls | train | def do_ls(self, table=None):
""" List all tables or print details of one table """
if table is None:
fields = OrderedDict(
[
("Name", "name"),
("Status", "status"),
("Read", "total_read_throughput"),
... | python | {
"resource": ""
} |
q246528 | DQLClient.complete_ls | train | def complete_ls(self, text, *_):
""" Autocomplete for ls """ | python | {
"resource": ""
} |
q246529 | DQLClient.do_local | train | def do_local(self, host="localhost", port=8000):
"""
Connect to a local DynamoDB instance. Use 'local off' to disable.
> local
> local host=localhost port=8001
> local off
"""
port = int(port)
| python | {
"resource": ""
} |
q246530 | DQLClient.do_use | train | def do_use(self, region):
"""
Switch the AWS region
> use us-west-1
> use us-east-1
"""
if self._local_endpoint is not None:
host, port = self._local_endpoint # pylint: disable=W0633
self.engine.connect(
| python | {
"resource": ""
} |
q246531 | DQLClient.complete_use | train | def complete_use(self, text, *_):
""" Autocomplete for | python | {
"resource": ""
} |
q246532 | DQLClient.do_throttle | train | def do_throttle(self, *args):
"""
Set the allowed consumed throughput for DQL.
# Set the total allowed throughput across all tables
> throttle 1000 100
# Set the default allowed throughput per-table/index
> throttle default 40% 20%
# Set the allowed throughput on... | python | {
"resource": ""
} |
q246533 | DQLClient.do_unthrottle | train | def do_unthrottle(self, *args):
"""
Remove the throughput limits for DQL that were set with 'throttle'
# Remove all limits
> unthrottle
# Remove the limit on total allowed throughput
> unthrottle total
# Remove the default limit
> unthrottle default
... | python | {
"resource": ""
} |
q246534 | DQLClient.completedefault | train | def completedefault(self, text, line, *_):
""" Autocomplete table names in queries """
tokens = line.split()
try:
before = tokens[-2]
complete = before.lower() in ("from", "update", "table", "into")
if tokens[0].lower() == "dump":
complete = Tr... | python | {
"resource": ""
} |
q246535 | DQLClient._run_cmd | train | def _run_cmd(self, command):
""" Run a DQL command """
if self.throttle:
tables = self.engine.describe_all(False)
limiter = self.throttle.get_limiter(tables)
else:
limiter = None
self.engine.rate_limit = limiter
results = self.engine.execute(co... | python | {
"resource": ""
} |
q246536 | DQLClient.run_command | train | def run_command(self, command):
""" Run a command passed in from the command line | python | {
"resource": ""
} |
q246537 | function | train | def function(name, *args, **kwargs):
""" Construct a parser for a standard function format """
if kwargs.get("caseless"):
name = upkey(name)
else:
name = Word(name)
fxn_args = None
for i, arg in enumerate(args):
if i == 0:
fxn_args = arg
else:
... | python | {
"resource": ""
} |
q246538 | make_interval | train | def make_interval(long_name, short_name):
""" Create an interval segment """
return Group(
Regex("(-+)?[0-9]+")
+ (
upkey(long_name + "s")
| Regex(long_name | python | {
"resource": ""
} |
q246539 | create_throughput | train | def create_throughput(variable=primitive):
""" Create a throughput specification """
return (
Suppress(upkey("throughput") | upkey("tp")) | python | {
"resource": ""
} |
q246540 | create_throttle | train | def create_throttle():
""" Create a THROTTLE statement """
throttle_amount = "*" | Combine(number + "%") | number
return Group(
| python | {
"resource": ""
} |
q246541 | _global_index | train | def _global_index():
""" Create grammar for a global index declaration """
var_and_type = var + Optional(type_)
global_dec = Suppress(upkey("global")) + index
range_key_etc = Suppress(",") + Group(throughput) | Optional(
Group(Suppress(",") + var_and_type).setResultsName("range_key")
) + Opt... | python | {
"resource": ""
} |
q246542 | create_create | train | def create_create():
""" Create the grammar for the 'create' statement """
create = upkey("create").setResultsName("action")
hash_key = Group(upkey("hash") + upkey("key"))
range_key = Group(upkey("range") + upkey("key"))
local_index = Group(
index
+ Suppress("(")
+ primitive... | python | {
"resource": ""
} |
q246543 | create_delete | train | def create_delete():
""" Create the grammar for the 'delete' statement """
delete = upkey("delete").setResultsName("action")
return (
delete
+ from_
+ table
| python | {
"resource": ""
} |
q246544 | create_insert | train | def create_insert():
""" Create the grammar for the 'insert' statement """
insert = upkey("insert").setResultsName("action")
# VALUES
attrs = Group(delimitedList(var)).setResultsName("attrs")
value_group = Group(Suppress("(") + delimitedList(value) + Suppress(")"))
values = Group(delimitedList(... | python | {
"resource": ""
} |
q246545 | _create_update_expression | train | def _create_update_expression():
""" Create the grammar for an update expression """
ine = (
Word("if_not_exists")
+ Suppress("(")
+ var
+ Suppress(",")
+ var_val
+ Suppress(")")
)
list_append = (
Word("list_append")
+ Suppress("(")
... | python | {
"resource": ""
} |
q246546 | create_update | train | def create_update():
""" Create the grammar for the 'update' statement """
update = upkey("update").setResultsName("action")
returns, none, all_, updated, old, new = map(
upkey, ["returns", "none", "all", "updated", "old", "new"]
)
return_ = returns + Group(
none | (all_ + old) | (al... | python | {
"resource": ""
} |
q246547 | create_alter | train | def create_alter():
""" Create the grammar for the 'alter' statement """
alter = upkey("alter").setResultsName("action")
prim_or_star = primitive | "*"
set_throughput = (
Suppress(upkey("set"))
+ Optional(Suppress(upkey("index")) + var.setResultsName("index"))
+ create_throughpu... | python | {
"resource": ""
} |
q246548 | create_dump | train | def create_dump():
""" Create the grammar for the 'dump' statement """
dump = upkey("dump").setResultsName("action")
return (
dump
| python | {
"resource": ""
} |
q246549 | create_load | train | def create_load():
""" Create the grammar for the 'load' statement """
load = upkey("load").setResultsName("action")
return (
load
| python | {
"resource": ""
} |
q246550 | create_parser | train | def create_parser():
""" Create the language parser """
select = create_select()
scan = create_scan()
delete = create_delete()
update = create_update()
insert = create_insert()
create = create_create()
drop = create_drop()
alter = create_alter()
dump = create_dump()
load = cr... | python | {
"resource": ""
} |
q246551 | main | train | def main():
""" Start the DQL client. """
parse = argparse.ArgumentParser(description=main.__doc__)
parse.add_argument("-c", "--command", help="Run this command and exit")
region = os.environ.get("AWS_REGION", "us-west-1")
parse.add_argument(
"-r",
"--region",
default=region,... | python | {
"resource": ""
} |
q246552 | SwaggerParser.build_definitions_example | train | def build_definitions_example(self):
"""Parse all definitions in the swagger specification."""
for | python | {
"resource": ""
} |
q246553 | SwaggerParser.build_one_definition_example | train | def build_one_definition_example(self, def_name):
"""Build the example for the given definition.
Args:
def_name: Name of the definition.
Returns:
True if the example has been created, False if an error occured.
"""
if def_name in self.definitions_example... | python | {
"resource": ""
} |
q246554 | SwaggerParser.check_type | train | def check_type(value, type_def):
"""Check if the value is in the type given in type_def.
Args:
value: the var to test.
type_def: string representing the type in swagger.
Returns:
True if the type is correct, False otherwise.
"""
if type_def =... | python | {
"resource": ""
} |
q246555 | SwaggerParser.get_example_from_prop_spec | train | def get_example_from_prop_spec(self, prop_spec, from_allof=False):
"""Return an example value from a property specification.
Args:
prop_spec: the specification of the property.
from_allof: whether these properties are part of an
allOf section
Ret... | python | {
"resource": ""
} |
q246556 | SwaggerParser._get_example_from_properties | train | def _get_example_from_properties(self, spec):
"""Get example from the properties of an object defined inline.
Args:
prop_spec: property specification you want an example of.
Returns:
An example for the given spec
A boolean, whether we had additionalPropertie... | python | {
"resource": ""
} |
q246557 | SwaggerParser._get_example_from_basic_type | train | def _get_example_from_basic_type(type):
"""Get example from the given type.
Args:
type: the type you want an example of.
Returns:
An array with two example values of the given type.
"""
if type == 'integer':
return [42, 24]
elif type ... | python | {
"resource": ""
} |
q246558 | SwaggerParser._definition_from_example | train | def _definition_from_example(example):
"""Generates a swagger definition json from a given example
Works only for simple types in the dict
Args:
example: The example for which we want a definition
Type is DICT
Returns:
A dict that is the ... | python | {
"resource": ""
} |
q246559 | SwaggerParser._example_from_allof | train | def _example_from_allof(self, prop_spec):
"""Get the examples from an allOf section.
Args:
prop_spec: property specification you want an example of.
Returns:
An example dict
"""
| python | {
"resource": ""
} |
q246560 | SwaggerParser._example_from_definition | train | def _example_from_definition(self, prop_spec):
"""Get an example from a property specification linked to a definition.
Args:
prop_spec: specification of the property you want an example of.
Returns:
An example.
"""
# Get value from definition
def... | python | {
"resource": ""
} |
q246561 | SwaggerParser._example_from_complex_def | train | def _example_from_complex_def(self, prop_spec):
"""Get an example from a property specification.
In case there is no "type" key in the root of the dictionary.
Args:
prop_spec: property specification you want an example of.
Returns:
An example.
"""
... | python | {
"resource": ""
} |
q246562 | SwaggerParser._example_from_array_spec | train | def _example_from_array_spec(self, prop_spec):
"""Get an example from a property specification of an array.
Args:
prop_spec: property specification you want an example of.
Returns:
An example array.
"""
# if items is a list, then each item has its own sp... | python | {
"resource": ""
} |
q246563 | SwaggerParser.get_dict_definition | train | def get_dict_definition(self, dict, get_list=False):
"""Get the definition name of the given dict.
Args:
dict: dict to test.
get_list: if set to true, return a list of definition that match the body.
if False, only return the first.
Returns:
... | python | {
"resource": ""
} |
q246564 | SwaggerParser.validate_additional_properties | train | def validate_additional_properties(self, valid_response, response):
"""Validates additional properties. In additional properties, we only
need to compare the values of the dict, not the keys
Args:
valid_response: An example response (for example generated in
... | python | {
"resource": ""
} |
q246565 | SwaggerParser.validate_definition | train | def validate_definition(self, definition_name, dict_to_test, definition=None):
"""Validate the given dict according to the given definition.
Args:
definition_name: name of the the definition.
dict_to_test: dict to test.
Returns:
True if the given dict match ... | python | {
"resource": ""
} |
q246566 | SwaggerParser._validate_type | train | def _validate_type(self, properties_spec, value):
"""Validate the given value with the given property spec.
Args:
properties_dict: specification of the property to check (From definition not route).
value: value to check.
Returns:
True if the value is valid ... | python | {
"resource": ""
} |
q246567 | SwaggerParser.get_paths_data | train | def get_paths_data(self):
"""Get data for each paths in the swagger specification.
Get also the list of operationId.
"""
for path, path_spec in self.specification['paths'].items():
path = u'{0}{1}'.format(self.base_path, path)
self.paths[path] = {}
#... | python | {
"resource": ""
} |
q246568 | SwaggerParser._add_parameters | train | def _add_parameters(self, parameter_map, parameter_list):
"""Populates the given parameter map with the list of parameters provided, resolving any reference objects encountered.
Args:
parameter_map: mapping from parameter names to parameter objects
parameter_list: list of either... | python | {
"resource": ""
} |
q246569 | SwaggerParser.get_path_spec | train | def get_path_spec(self, path, action=None):
"""Get the specification matching with the given path.
Args:
path: path we want the specification.
action: get the specification for the given action.
Returns:
A tuple with the base name of the path and the specifi... | python | {
"resource": ""
} |
q246570 | SwaggerParser.validate_request | train | def validate_request(self, path, action, body=None, query=None):
"""Check if the given request is valid.
Validates the body and the query
# Rules to validate the BODY:
# Let's limit this to mime types that either contain 'text' or 'json'
# 1. if body is None, there m... | python | {
"resource": ""
} |
q246571 | SwaggerParser._validate_query_parameters | train | def _validate_query_parameters(self, query, action_spec):
"""Check the query parameter for the action specification.
Args:
query: query parameter to check.
action_spec: specification of the action.
Returns:
True if the query is valid.
"""
pro... | python | {
"resource": ""
} |
q246572 | SwaggerParser._validate_body_parameters | train | def _validate_body_parameters(self, body, action_spec):
"""Check the body parameter for the action specification.
Args:
body: body parameter to check.
action_spec: specification of the action.
Returns:
True if the body is valid.
A string containi... | python | {
"resource": ""
} |
q246573 | SwaggerParser.get_response_example | train | def get_response_example(self, resp_spec):
"""Get a response example from a response spec.
"""
if 'schema' in resp_spec.keys():
if '$ref' in resp_spec['schema']: # Standard definition
definition_name = self.get_definition_name_from_ref(resp_spec['schema']['$ref'])
... | python | {
"resource": ""
} |
q246574 | SwaggerParser.get_request_data | train | def get_request_data(self, path, action, body=None):
"""Get the default data and status code of the given path + action request.
Args:
path: path of the request.
action: action of the request(get, post, delete...)
body: body sent, used to sent it back for post reques... | python | {
"resource": ""
} |
q246575 | SwaggerParser.get_send_request_correct_body | train | def get_send_request_correct_body(self, path, action):
"""Get an example body which is correct to send to the given path with the given action.
Args:
path: path of the request
action: action of the request (get, post, put, delete)
Returns:
A dict representin... | python | {
"resource": ""
} |
q246576 | normalize_hex | train | def normalize_hex(hex_value):
"""
Normalize a hexadecimal color value to 6 digits, lowercase.
"""
match = HEX_COLOR_RE.match(hex_value)
if match is None:
raise ValueError(
u"'{}' is not a valid hexadecimal color value.".format(hex_value)
)
| python | {
"resource": ""
} |
q246577 | html5_parse_simple_color | train | def html5_parse_simple_color(input):
"""
Apply the simple color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
#
# 2. If input is not exactly seven characters long, then return an
# error.
if not isinstance(input, unicode) or len(inp... | python | {
"resource": ""
} |
q246578 | html5_serialize_simple_color | train | def html5_serialize_simple_color(simple_color):
"""
Apply the serialization algorithm for a simple color from section
2.4.6 of HTML5.
"""
red, green, blue = simple_color
# 1. Let result be a string consisting of a single "#" (U+0023)
# character.
result = u'#'
# 2. Convert the ... | python | {
"resource": ""
} |
q246579 | html5_parse_legacy_color | train | def html5_parse_legacy_color(input):
"""
Apply the legacy color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
if not isinstance(input, unicode):
raise ValueError(
u"HTML5 legacy color parsing requires a Unicode string as input.... | python | {
"resource": ""
} |
q246580 | Record.create | train | def create(cls, data, id_=None, **kwargs):
r"""Create a new record instance and store it in the database.
#. Send a signal :data:`invenio_records.signals.before_record_insert`
with the new record as parameter.
#. Validate the new record data.
#. Add the new record in the da... | python | {
"resource": ""
} |
q246581 | Record.get_record | train | def get_record(cls, id_, with_deleted=False):
"""Retrieve the record by id.
Raise a database exception if the record does not exist.
:param id_: record ID.
:param with_deleted: If `True` then it includes deleted records.
:returns: The :class:`Record` instance.
"""
... | python | {
"resource": ""
} |
q246582 | Record.get_records | train | def get_records(cls, ids, with_deleted=False):
"""Retrieve multiple records by id.
:param ids: List of record IDs.
:param with_deleted: If `True` then it includes deleted records.
:returns: A list of :class:`Record` instances.
"""
with db.session.no_autoflush:
... | python | {
"resource": ""
} |
q246583 | Record.patch | train | def patch(self, patch):
"""Patch record metadata.
:params patch: Dictionary of record metadata.
| python | {
"resource": ""
} |
q246584 | Record.commit | train | def commit(self, **kwargs):
r"""Store changes of the current record instance in the database.
#. Send a signal :data:`invenio_records.signals.before_record_update`
with the current record to be committed as parameter.
#. Validate the current record data.
#. Commit the curre... | python | {
"resource": ""
} |
q246585 | Record.revert | train | def revert(self, revision_id):
"""Revert the record to a specific revision.
#. Send a signal :data:`invenio_records.signals.before_record_revert`
with the current record as parameter.
#. Revert the record to the revision id passed as parameter.
#. Send a signal :data:`inven... | python | {
"resource": ""
} |
q246586 | _RecordsState.validate | train | def validate(self, data, schema, **kwargs):
"""Validate data using schema with ``JSONResolver``."""
if not isinstance(schema, dict):
schema = {'$ref': schema}
return validate(
data,
| python | {
"resource": ""
} |
q246587 | AudioVisual.to_filelink | train | def to_filelink(self):
"""
Checks is the status of the conversion is complete and, if so, converts to a Filelink
*returns* [Filestack.Filelink]
```python
filelink = av_convert.to_filelink()
```
"""
if self.status != 'completed':
return 'Audio... | python | {
"resource": ""
} |
q246588 | Filelink._return_tag_task | train | def _return_tag_task(self, task):
"""
Runs both SFW and Tags tasks
"""
if self.security is None:
raise Exception('Tags require security')
tasks = [task]
transform_url = get_transform_url(
tasks, handle=self.handle, security=self.security,
... | python | {
"resource": ""
} |
q246589 | Filelink.url | train | def url(self):
"""
Returns the URL for the instance, which can be used
to retrieve, delete, and overwrite the file. If security is enabled, signature and policy parameters will
be included,
*returns* [String]
```python
| python | {
"resource": ""
} |
q246590 | ImageTransformationMixin.zip | train | def zip(self, store=False, store_params=None):
"""
Returns a zip file of the current transformation. This is different from
the zip function that lives on the Filestack Client
*returns* [Filestack.Transform]
"""
params = locals()
params.pop('store')
| python | {
"resource": ""
} |
q246591 | ImageTransformationMixin.av_convert | train | def av_convert(self, preset=None, force=None, title=None, extname=None, filename=None,
width=None, height=None, upscale=None, aspect_mode=None, two_pass=None,
video_bitrate=None, fps=None, keyframe_interval=None, location=None,
watermark_url=None, watermark_top=N... | python | {
"resource": ""
} |
q246592 | ImageTransformationMixin.add_transform_task | train | def add_transform_task(self, transformation, params):
"""
Adds a transform task to the current instance and returns it
*returns* Filestack.Transform
"""
if not isinstance(self, filestack.models.Transform):
instance = filestack.models.Transform(apikey=self.apikey, sec... | python | {
"resource": ""
} |
q246593 | CommonMixin.download | train | def download(self, destination_path, params=None):
"""
Downloads a file to the given local path and returns the size of the downloaded file if successful
*returns* [Integer]
```python
from filestack import Client
client = Client('API_KEY', security=sec)
fileli... | python | {
"resource": ""
} |
q246594 | CommonMixin.get_content | train | def get_content(self, params=None):
"""
Returns the raw byte content of a given Filelink
*returns* [Bytes]
```python
from filestack import Client
client = Client('API_KEY')
filelink = client.upload(filepath='/path/to/file/foo.jpg')
byte_content = fileli... | python | {
"resource": ""
} |
q246595 | CommonMixin.get_metadata | train | def get_metadata(self, params=None):
"""
Metadata provides certain information about a Filehandle, and you can specify which pieces
of information you will receive back by passing in optional parameters.
```python
from filestack import Client
client = Client('API_KEY')... | python | {
"resource": ""
} |
q246596 | CommonMixin.delete | train | def delete(self, params=None):
"""
You may delete any file you have uploaded, either through a Filelink returned from the client or one you have initialized yourself.
This returns a response of success or failure. This action requires security.abs
*returns* [requests.response]
... | python | {
"resource": ""
} |
q246597 | CommonMixin.overwrite | train | def overwrite(self, url=None, filepath=None, params=None):
"""
You may overwrite any Filelink by supplying a new file. The Filehandle will remain the same.
*returns* [requests.response]
```python
from filestack import Client, security
# a policy requires at least an ex... | python | {
"resource": ""
} |
q246598 | validate | train | def validate(policy):
"""
Validates a policy and its parameters and raises an error if invalid
"""
for param, value in policy.items():
if param not in ACCEPTED_SECURITY_TYPES.keys():
raise SecurityError('Invalid Security Parameter: {}'.format(param))
if type(value) != ACCEP... | python | {
"resource": ""
} |
q246599 | security | train | def security(policy, app_secret):
"""
Creates a valid signature and policy based on provided app secret and
parameters
```python
from filestack import Client, security
# a policy requires at least an expiry
policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
sec = security(... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.