Format docstring to be able to entry in DeepL or GoogleTranslate
Project description
docstringFormatter
Format docstring to be able to entry in DeepL or GoogleTranslate.
Main function:
1. Remove newline
2. Reduce extra spaces
3. Output result as txt-file
"docstringFormatter" releases you from boring duties to reform the docstring string in the Entry of DeepL or GoogleTranslate so that these get correct translation.
DEMO
Below show the console display when get docstring of logging.Logger
object.
____ "logging" is one of the standard libraries of Python.
Compared with "Original Sentence" section, the strings of "Formatted Sentence" is converted in one line by removing newlines and extra spaces that consist of indention of left side.
Only the left thing you do is copy & paste the strings of "Formatted Sentence" in the Entry of Translating Web Application like DeepL or GoogleTranslate.
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
Formatted Sentence
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Instances of the Logger class represent a single logging channel. A "logging channel" indicates an area of an application. Exactly how an "area" is defined is up to the application developer. Since an application can have any number of areas, logging channels are identified by a unique string. Application areas can be nested (e.g. an area of "input processing" might include sub-areas "read CSV files", "read XLS files" and "read Gnumeric files"). To cater for this natural nesting, channel names are organized into a namespace hierarchy where levels are separated by periods, much like the Java or Python package namespace. So in the instance given above, channel names might be "input" for the upper level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels. There is no arbitrary limit to the depth of nesting.
■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
Original Sentence
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Instances of the Logger class represent a single logging channel. A
"logging channel" indicates an area of an application. Exactly how an
"area" is defined is up to the application developer. Since an
application can have any number of areas, logging channels are identified
by a unique string. Application areas can be nested (e.g. an area
of "input processing" might include sub-areas "read CSV files", "read
XLS files" and "read Gnumeric files"). To cater for this natural nesting,
channel names are organized into a namespace hierarchy where levels are
separated by periods, much like the Java or Python package namespace. So
in the instance given above, channel names might be "input" for the upper
level, and "input.csv", "input.xls" and "input.gnu" for the sub-levels.
There is no arbitrary limit to the depth of nesting.
Features
- Easy to Use
__ You can use the function just adjust content ofmain()
in code. - Easy to Read
__ Console display is designated simply and reasonably. - Easy to Introduce
__ Mainly 2ways to use are described in this README.
Requirement
"docstringFormatter" (ver.1.0.0) doesn't require third-party Library. Probably, it works on over Python3.7.x Envelopment.
- Python 3.7.x
Installation
Install "docstringFormatter" with pip command.
pip install docstringFormatter
Usage
There are 2 way for usage. One hand is (1) script running alone. Another is (2) import functions (or whole module).
(1) Run the "docstringFormatter.py" and use the main() in itself
Open the python file named "docstringFormatter.py" with any text editor and so on.
Then change the assignment for var name_object
in main()
to the identifier of the object you want to get docstring.
If you want the result as a txt-file, revalue the arguments of txt_outputter()
appropriately.
See the comments in the below code for details.
def main():
"""
You can try the function here.
"""
# If the object requires import of module, you do so like the under example 'logging'
import logging
# Assign the identifier of object to 'name_object'
name_object = logging.Logger
# Default Setting at main() --> name_obj=name_object, times_red=2, rmv_t=True, rmv_n=True
str_result = docstring_formatter(name_obj=name_object, times_red=2, rmv_t=True, rmv_n=True)
console_constructor(str_result, name_object.__doc__)
# If you need the output txt-file, revalue the 'output' arg to True.
# You can change the output file name by rewriting 'filename' arg.
txt_outputter(output=False, filename='docstring_formatted')
# When you want the output is the same as 'Original Sentence' displayed on console,
# revalue the arguments setting of docstring_formatter() like below.
#
# Setting at main() --> name_obj=name_object, times_red=0, rmv_t=False, rmv_n=False
(2) Importing three functions by copy&paste contents of main()
Introducing to your code is also simple.
First import at top in your cord.The example is shown below.
And Just copy & paste the contents of main()
to the appropriate line.
Remember to delete the left side indent of pasted code.
# import sentences example in case you'll copy & paste contents of main()
from src.docstringFormatter import docstring_formatter
from src.docstringFormatter import console_constructor
from src.docstringFormatter import txt_outputter
Import as a module not multi functions
Sure, you can import this script as a module. If you can code, try it yourself!
Note
I don't test the Environments under Linux and Mac.
Author
-
Auther: Aoi Natsuki (蒼井 夏樹)
-
Work: Blau Tine
-
E-mail: blautinte8
☆
gmail.com
- - - - - > Replace '☆' for '@' -
Twitter ( or "X")
- Auther
- Aoi Natsuki(蒼井 夏樹)
- Workplace
- Blau Tinte
-
LinkedIn: Aoi Natsuki
License
"docstringFormatter" is under MIT license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file docstringFormatter-1.0.0.tar.gz
.
File metadata
- Download URL: docstringFormatter-1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbdef559826c3f65c34d6e033e6fbf033b82a9716733ef7abfd90ca1fa1eedf5 |
|
MD5 | fe32892d935ab7fb67c796552cdef913 |
|
BLAKE2b-256 | ec7867becf81a99fd4a00453311debf3169dba03079f957a3ad648d800cea8ab |
File details
Details for the file docstringFormatter-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: docstringFormatter-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaaf24b8587a9ea127442c0fc34f034775068daef77f87558ad83d1aaf15b54d |
|
MD5 | b9408951094f22adb1bef5fb72d95e7f |
|
BLAKE2b-256 | 8f9ccdb9e48a194e083300bd011b429f2a2d514482e7372e329d35ab88a479dc |