text stringlengths 0 828 |
|---|
:return: a entrypoint |
:rtype kser.entry.Entrypoint |
"""""" |
return cls( |
uuid=kmsg.uuid, params=kmsg.params, result=kmsg.result, |
metadata=kmsg.metadata |
)" |
4092,"def save_as(self, filename=None): |
"""""" |
Dumps object contents into file on disk. |
Args: |
filename (optional): defaults to self.filename. If passed, self.filename |
will be updated to filename. |
"""""" |
if filename is None: |
filename = self.filename |
if filename is None: |
filename = self.default_filename |
if filename is None: |
raise RuntimeError(""Class '{}' has no default filename"".format(self.__class__.__name__)) |
self._do_save_as(filename) |
self.filename = filename" |
4093,"def load(self, filename=None): |
""""""Loads file and registers filename as attribute."""""" |
assert not self.__flag_loaded, ""File can be loaded only once"" |
if filename is None: |
filename = self.default_filename |
assert filename is not None, \ |
""{0!s} class has no default filename"".format(self.__class__.__name__) |
# Convention: trying to open empty file is an error, |
# because it could be of (almost) any type. |
size = os.path.getsize(filename) |
if size == 0: |
raise RuntimeError(""Empty file: '{0!s}'"".format(filename)) |
self._test_magic(filename) |
self._do_load(filename) |
self.filename = filename |
self.__flag_loaded = True" |
4094,"def init_default(self): |
"""""" |
Initializes object with its default values |
Tries to load self.default_filename from default |
data directory. For safety, filename is reset to None so that it doesn't point to the |
original file. |
"""""" |
import f311 |
if self.default_filename is None: |
raise RuntimeError(""Class '{}' has no default filename"".format(self.__class__.__name__)) |
fullpath = f311.get_default_data_path(self.default_filename, class_=self.__class__) |
self.load(fullpath) |
self.filename = None" |
4095,"def availability(self, availability): |
""""""Sets the availability of this Product. |
:param availability: The availability of this Product. |
:type: str |
"""""" |
allowed_values = [""available"", ""comingSoon"", ""retired""] |
if availability is not None and availability not in allowed_values: |
raise ValueError( |
""Invalid value for `availability` ({0}), must be one of {1}"" |
.format(availability, allowed_values) |
) |
self._availability = availability" |
4096,"def stock_status(self, stock_status): |
""""""Sets the stock_status of this Product. |
:param stock_status: The stock_status of this Product. |
:type: str |
"""""" |
allowed_values = [""available"", ""alert"", ""unavailable""] |
if stock_status is not None and stock_status not in allowed_values: |
raise ValueError( |
""Invalid value for `stock_status` ({0}), must be one of {1}"" |
.format(stock_status, allowed_values) |
) |
self._stock_status = stock_status" |
4097,"def create_product(cls, product, **kwargs): |
""""""Create Product |
Create a new Product |
This method makes a synchronous HTTP request by default. To make an |
asynchronous HTTP request, please pass async=True |
>>> thread = api.create_product(product, async=True) |
>>> result = thread.get() |
:param async bool |
:param Product product: Attributes of product to create (required) |
:return: Product |
If the method is called asynchronously, |
returns the request thread. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.