def __init__(self, fp, location=None): """ Constructor. When extending this class do not forget to call ``super``. This sets up base instance variables which can be used thoughtout the instance. Arguments --------- fp : werkzeug.datastructures.FileStorage, str A FileStorage instance or absolute path to a file Keyword Arguments ----------------- location : str, optional Relative location directory, this is appended to the ``STORE_PATH``, default None """ # The base store path for the provider self.store_path = self.join(current_app.config['STORE_PATH']) # Save the fp - could be a FileStorage instance or a path self.fp = fp # Get the filename if is_path(fp): self.filename = os.path.basename(fp) else: if not isinstance(fp, FileStorage): raise ValueError( 'File pointer must be an instance of a ' 'werkzeug.datastructures.FileStorage') self.filename = fp.filename # Save location self.location = location # Appends location to the store path if location: self.store_path = self.join(self.store_path, location)
def __init__(self, fp, location=None): """ Constructor. When extending this class do not forget to call ``super``. This sets up base instance variables which can be used thoughtout the instance. Arguments --------- fp : werkzeug.datastructures.FileStorage, str A FileStorage instance or absolute path to a file Keyword Arguments ----------------- location : str, optional Relative location directory, this is appended to the ``STORE_PATH``, default None """ # The base store path for the provider self.store_path = self.join(current_app.config['STORE_PATH']) # Save the fp - could be a FileStorage instance or a path self.fp = fp # Get the filename if is_path(fp): self.filename = os.path.basename(fp) else: if not isinstance(fp, FileStorage): raise ValueError('File pointer must be an instance of a ' 'werkzeug.datastructures.FileStorage') self.filename = fp.filename # Save location self.location = location # Appends location to the store path if location: self.store_path = self.join(self.store_path, location)