simple-file-user 0.2.1
Package for easy working with files.
License: MIT
Keywords: files file

Из России? Тебе сюда --> <a href="https://zen.yandex.ru/media/id/60856790ae47bf185f78b82d/zdravstvuite-eto-ne-statia-a-dokumentaciia-k-moemu-paketu-v-pypi-608f77907ffcba2d9e3b78fc">русскоязычная версия</a>.<br>
<br>
Simple_file_user is the package for easy working with files.
This package has some functions and one class for working with files.
<h2>Installing</h2>
To install this package write in command line:<br>
<code>python -m pip install simple_file_user</code>
<h2>Quick start.</h2>
To import class use:<br>
<code>from simple_file_user.File import File</code><br>
This imports File class from package. Let's make new file with it:<br>
<code>file = File("file.txt", "utf-8", True)</code><br>
Let's write something into our file:<br>
<code>file.rewrite("Something.")</code><br>
And check if has it written into file by read function:<br>
<code>file.read()</code><br>
Output:<br>
<code>Something</code>
<h2>Importing</h2>
<code>
 import simple_file_user # Import all, but you can call package's facilities only with the prefix simple_file_user.<br>
 from simple_file_user import * # Import all from the package.<br>
 from simple_file_user import name_of_function # Import certain function or functions.<br>
 from simple_file_user.File import File # Import File class.<br>
</code>
<h2>Functions overview</h2>
This is list of functions included this package:
<ul>
 <li><code>read(path: str, encoding: str = "utf-8", binary_mode: bool = False) -> str</code> ---- Read file and return it's content.</li>
 <li><code>rewrite(path: str, content: str, encoding: str = "utf-8") -> int</code> ---- Clear file and write content into it. Return amount of written symbols.</li>
 <li><code>add(path: str, content: str, encoding = "utf-8") -> int</code> ---- Add content into file. Return amount of written symbols.</li>
 <li><code>remove(path: str) -> None</code> ---- Remove file.</li>
 <li><code>rename(path: str, new_name: str) -> None</code> ---- Rename file (path).</li>
 <li><code>getSize(path: str) -> int</code> ---- Return size of file (path) in bytes.</li>
 <li><code>recode(path: str, oldEncoding: str, newEncoding: str) -> None</code> ---- Recode file (path) from oldEncoding to newEncoding.</li>
 <li><code>getExtension(path: str) -> str</code> ---- Return extension of file.</li>
 <li><code>writeToFile(path: str, encoding: str = "utf-8")</code> ---- It is decorator. Return function that write to file (path) returning of decorated callable object.</li>
 <li><code>addToFile(path: str, encoding: str = "utf-8")</code> ---- It is decorator. Return function that add to file (path) returning of decorated callable object.</li>
</ul>
If you want to learn more about them use <code>help(name_of_function)</code>. So you will get a more extended description.
<h2>File class</h2>
<code>File(path: str, encoding: str = "utf-8", new: bool = False, binary_mode: bool = False)</code>
File object normalises and makes absolute path before it saves it. If new is true it creates new file. Already existing file on this path clears.
If binary is true file opens like binary, so read method will return bytes. Also binary file doesn't have encoding,
so you'll get Exception if you try to get encoding of this file.
<h3>Methods overview</h3>
<ul>
 <li><code>read() -> str</code> ---- Read file and return it's content.</li>
 <li><code>write(content: str, mod: str) -> int</code> ---- Write content into file by mod.</li>
 <li><code>rewrite(content: str) -> int</code> ---- Clear file and write content into it. Return amount of written symbols.</li>
 <li><code>add(content: str) -> int</code> ---- Add content into file. Return amount of written symbols.</li>
 <li><code>readLine(number_of_line: int) -> str</code> ---- Read line from file.</li>
 <li><code>rename(new_name: str) -> None</code> ---- Rename file.</li>
 <li><code>getSize() -> int</code> ---- Return size of file in bytes.</li>
 <li><code>getName() -> str</code> ---- Return name of file.</li>
 <li><code>getNameWithoutExt() -> str</code> ----  Return name without extension.</li>
 <li><code>getEncoding() -> str</code> ---- Return encoding of file.</li>
 <li><code>getPath() -> str</code> ---- Return path to file.</li>
 <li><code>getPathWithoutName() -> str</code> ---- Return path without name.</li>
 <li><code>getExtension() -> str</code> ---- Return extension of file.</li>
 <li><code>isBinary() -> bool</code> ---- Return is file binary.</li>
 <li><code>changeExtension(newExtension: str) -> None</code> ---- Change extension of file.</li>
 <li><code>changeEncoding(newEncoding: str) -> None</code> ---- </li>
 <li><code>recode(newEncoding: str) -> None</code> ---- Recode file to newEncoding</li>
 <li><code>remove() -> None</code> ---- Remove file and destroy object.</li>
 <li><code>readLine(number_of_line: int) -> str</code> ---- Return line from file (File splits by \n symbol).</li>
 <li><code>split(key: str) -> list</code> ---- Return splited file's content.</li>
 <li><code>rsplit(key: str) -> list</code> ---- Return reversed splited file's content.</li>
</ul>
<h3>Compairing File objects.</h3>
You can compair File objects between of them. If you try to compair File object and something else, you will get a TypeError. 
Compairing operators <code>==</code> and <code>!=</code> compair content of given Files. Others (<code>< > <= >=</code>) compair their size.