def validate(self): if self.interactive: print "\nValidating product arguments ..." # should have a valid product name, self._name = validate_product_name(self._name) if self._category: if not self._category in Product.category_names(): raise ActionError("Unrecognized category.") else: raise ActionError("Category is required.") if not self._description: raise ActionError("Description is required.") # ptask if not isinstance(self._ptask, PTask): try: self._ptask = PTask.get(self._ptask) except PTaskError: raise ActionError("Could not determine ptask.") if self._version: self._ptask_version = self._ptask.version(self._version) else: self._ptask_version = self._ptask.latest_version if not self._ptask_version: raise ActionError("Could not determine ptask version.") if not self._note: self._note = "None" if self._path: if not os.path.exists(self._path): raise ActionError("Supplied path does not exist.") if (os.path.isdir(self._path) and not self._path.endswith(os.path.sep)): self._path += os.path.sep
def prompt(self): print "" product_display = " [{b}{p}{r}]".format( b=Style.bright, p=self._product, r=Style.reset, ) # category menu if not self._category: self._category = Output.prompt_menu( "Product categories", "{pd} category".format(pd=product_display), zip(*[Product.category_names()] * 2), ) # description if not self._description: self._description = Output.prompt( '{pd} description'.format(pd=product_display), blank=False, ) # file type if not self._file_type: if not self._file_type: self._file_type = Output.prompt( "{pd} file type".format(pd=product_display), blank=False, ) # resolution if not self._resolution: self._resolution = Output.prompt( "{pd} resolution (Return if none)".format(pd=product_display), blank=True, ) if not self._resolution: self._resolution = 'none'