sphinx-quickstart on Wed Jun 3 16:21:33 2020. You can adapt this file completely to your liking, but it should at least contain the root toctree directive.

Installation

pip install file_item

File

class file_item.File(path: Union[str, pathlib.PosixPath])

File object

__init__(path: Union[str, pathlib.PosixPath]) → None
Parameters:path (str) – file’s absolute path
static basedir(file_: str) → pathlib.PosixPath

Return file’s basedir

Parameters:file (str) – path to a file
Return PosixPath:
 path to the file’s folder
Example:
>>> from file_item import File
>>> basedir = File.basedir(__file__)
create_folder() → None

Create folder by file path if not exist

Return None:
Example:
>>> f = File('/home/user/test.csv')
>>> f.create_folder()
classmethod from_strings(folder_path: str, file_name: str) → file_item.file_item.File

Create a File object from strings

Parameters:
  • folder_path (str) – path to a folder
  • file_name (str) – file name
Return File:
Example:
>>> file_ = File.from_strings('/home/user/folder', 'test.csv')
static get_file_name(name: str, ext: Optional[str] = None, replacer: str = '-') → str

Will replace forbidden characters from the string

Forbidden symbols:

  • < (less than)

  • > (greater than)

  • : (colon)

  • ” (double quote)

  • / (forward slash)

  • (backslash)

  • (vertical bar or pipe)
  • ? (question mark)

    • (asterisk)
Examples:
>>> File.get_file_name('test*.csv')
... 'test-.csv'
>>> File.get_file_name('test*', ext='csv')
... 'test-.csv'
>>> File.get_file_name('test*.csv', replacer='_')
... 'test_.csv'
Parameters:
  • name (str) – file’s name
  • ext (str) – file’s extension, default None
  • replacer (str) – replacer for forbidden characters, default: -
Return str:

file name

name

File name