Welcome to py_everything’s Documentation!¶
Welcome to the Documentation for py_everything. You can find all the modules and how to use them here.
py_everything hopes to become a Python package that helps you write everything much faster and in a easier way.
Power of py_everything -¶
The basic usage for this package is given below:
>>> import py_everything
>>> from py_everything import search
>>> search.search_files('python', 'C:\Programming\\')
C:\Programming\python.txt
C:\Programming\projectpython.py
C:\Programming\py_everything-python.docx
>>> my_list = [2, 4, 5, 3, 7, 5, 6, 3 , 12 , 9, 6]
>>> py_everything.maths.avg(my_list)
5.636363636363637
Contributors -¶
People who have contributed to this project -
Modules, Functions, and Classes¶
Detailed Package List¶
Modules:¶
py_everything
py_everything.automation
py_everything.date_utils
py_everything.fileIO
py_everything.maths
py_everything.requestsLib
py_everything.search
py_everything.web
Functions:¶
py_everything:¶
hello_world
print_no_newline
clearPycache
install_modules
py_everything.automation:¶
email_bot
email_address_slicer
yt_downloader
roll_dice
timer
py_everything.date_utils:¶
get_date
get_date_time
get_time
get_custom_format
py_everything.fileIO:¶
read_file
write_file
clear_file
py_everything.maths:¶
add
subtract
multiply
divide
float_div
int_div
expo
mod
eval_exp
avg
py_everything.requestsLib:¶
getR
postR
putR
deleteR
patchR
optionsR
headR
getContent
getText
getJson
getHeader
getSpecificHeader
py_everything.search:¶
search_files
search_dirs
search_exts
search_list
py_evrything.web:¶
google_search
yt_search
github_search
so_search
amz_in_search
amz_com_search
pypi_search
rtdocs_search
open_new_tab
open_new_window
py_everything¶
Your First Program using this package¶
What’s the best way to write your first program than “Hello, World!”
Function name - hello_world()
No. of Parameters - 0
Parameters - No parameters
Clear pycache¶
Function name - clearPycache(path)
No. of Parameters - 1
Parameters - path
Usage -¶
>>> pye.clearPycache(path\to\pycache\folder)
True
Provide the pth to the folder where the “__pycache__” is located. For example - C:ProgrammingProjectsPython
Note - Do not provide __pycache__ in the path. That does not clear it. For example - C:ProgrammingProjectsPython__pycache__. This would return False.
Print without newline¶
Function name - print_no_newline(*args)
No. of Parameters - infinte
Parameters - *args
Usage -¶
>>> pye.print_no_newline("hello", "world", "this is printed without newline", ".")
hello world this is printed without newline .
Pass in the words you want to get printed without newline and That will be printed.
py_everything.automation¶
Send a mail with Python¶
Function name - email_bot(send_addr, password, recv_addr, body, server, port, sub=’No Subject’)
No. of Parameters - 7
Parameters - send_addr, password, recv_addr, body, server, port, sub=’No Subject’
Usage -¶
>>> my_addr = "your.email@add.ress"
>>> my_pass = "your password"
>>> to_addr = "recv.er@add.ress"
>>> my_body = "Email body"
>>> my_server = "your.smtp.server"
>>> my_port = "123"
>>> my_sub = "My Subject"
>>> pye.email_bot(my_addr, my_pass, to_addr, my_body, my_server, my_port, my_sub)
True
This function sends a mail to the address passed in recv_addr. sub is a optional parameter. The mail is sent from the value of sent_addr. sent_addr and password are used to authenticate with the server. The port is also very important. body, and sub are the Body and Subject of the email, respectively.
Note - Speacial settings must be enabled for this function to work properly. For e.g. - In Gmail you need to enable Less secure app access.
Slice an email address¶
Function name - email_address_slicer(full_addr)
No. of Parameters - 1
Parameters - full_addr
Usage -¶
>>> full_addr = 'long.demo.address@long-domain.com'
>>> pye.email_address_slicer(full_addr)
['long.demo.address', 'long-domain.com']
This function is usefull to get the username and domain of a email
address seperately. full_addr
takes in the the full email address
that is to sliced.
Roll the Dice!¶
Function name - roll_dice(dice1=True)
No. of Parameters - 1
Parameters - dice_1
Usage -¶
>>> pye.roll_dice(dice_1=True)
4
>>> pye.roll_dice(dice_1=False)
8
>>> pye.roll_dice(dice_1=True)
6
>>> pye.roll_dice(dice_1=False)
11
This function doesn’t need explanation but still. If dice_1
is True
then the number will be within th range of 1 to 6 but if dice_1
is
False the range is from 1 to 12. That is dice_1
signifies the no. of
dice being rolled. If True, 1 dice, else 2 die. It is True by default.
Run a timer¶
Function name - timer(seconds, audio_file)
No. of Parameters - 2
Parameters - seconds, audio_file
Usage -¶
>>> pye.timer(10, 'path/to/audio/file.mp3')
<---After 10 seconds, it plays the audio_file--->
This function countsdown seconds
untill it reaches 0 and then plays
audio_file
. Both parameters are required.
Start or run a app or executable.¶
Function name - start_app(drive, app_path, exe_name)
No. of Parameters - 3
Parameters - drive, app_path, exe_name
Usage -¶
>>> pye.start_app('C', 'path/to/exe_file/file_name.exe')
True
This function uses the 3 parameters to run any executable.
Note - In exe_path
, the full path, including exe name and extension
are to be provided, in drive
, only the letter is to be provided, the
colon(:) is to be ommited. For example - start_app(‘C’, ‘C:/Program
Files/company/exe_name.exe’).
- … toctree::
- caption
Basic:
py_everything.date_utils¶
Get Current Date and Time¶
Function Name - get_date_time()
No. of Parameters - 0
Parameters - None
Usage -¶
>>> pyeDate.get_date_time()
2021-03-07 18:08:19.018239
This function prints the current date and time.
py_everything.fileIO¶
Read Data from a File¶
Function Name - read_file(filename)
No. of Parameters - 1
Parameter - filename
Usage -¶
>>> pyeFiles.read_file('path/to/file')
Data of the file is returned.
This function reads the data of filename
and returns it.
Write Data to a File¶
Function Name - write_file(filename, writeData=’’)
No. of Parameters - 2
Parameter - filename, writeData
Usage -¶
>>> pyeFiles.write_file('path/to/file', writeData="Data to be written to the file.")
True
This function reads the file given in filename
, then clears all its
content and then writes writeData
to the file. If these steps are
successful, it returns True.
Clear or Erase Contents of a File¶
Function Name - write_file(filename)
No. of Parameters - 1
Parameter - filename
Usage -¶
>>> pyeFiles.clear_file('path/to/file')
True
This function reads the file given in filename
, then clears all its
contents. If the steps are successful, it returns True.
Make a New directory or Folder¶
Function Name - mk_dir(dir_name, path)
No. of Parameters - 2
Parameter - dir_name, path
Make a New File¶
Function Name - mk_file(file_name, path)
No. of Parameters - 2
Parameter - file_name, path
Usage -¶
>>> pyeFiles.mk_file('fileName.txt', 'path/to/file/location')
True
This function makes a new file named file_name
in path
. If steps
are successful, returns True.
Delete an Empty directory¶
Function Name - del_dir(path, dir_name)
No. of Parameters - 2
Parameter - path, dir_name
Delete a directory with Items(Recursive Deletion)¶
Function Name - del_dir_rec(path, dir_name)
No. of Parameters - 2
Parameter - path, dir_name
Delete a File¶
Function Name - del_file(path, file_name)
No. of Parameters - 2
Parameter - path, file_name
Usage -¶
>>> pyeFiles.del_file('fileName.txt', 'path/to/file/location')
True
This function deletes an existing file named file_name
that is in
path
. If steps are successful, returns True. Raises error if file
does not exist.
py_everything.maths¶
Add¶
Function Name - add(num1, num2, *args)
No. of Parameters - infinite
Parameters - num1, num2, *args
Usage -
>>> pyeMaths.add(1, 4, 3, 7, 3, 10, 13, 24)
65
Subtract¶
Function Name - subtract(num1, num2, *args)
No. of Parameters - infinite
Parameters - num1, num2, *args
Usage -
>>> pyeMaths.subtract(16, 4, 3)
9
Multiply¶
Function Name - multiply(num1, *args)
No. of Parameters - infinite
Parameters - num1, *args
Usage -
>>> pyeMaths.multiply(2, 4, 3)
24
Divide¶
Function Name - divide(num1, num2, type)
No. of Parameters - 3
Parameters - num1, num2, type
Usage -
>>> pyeMaths.divide(36, 3, 'float')
12.0
>>> pyeMaths.divide(36, 3, 'int')
12
Float Division¶
Function Name - float_div(num1, num2)
No. of Parameters - 2
Parameters - num1, num2
Usage -
>>> pyeMaths.float_div(36, 3)
12.0
Integer Division¶
Function Name - int_div(num1, num2)
No. of Parameters - 2
Parameters - num1, num2
Usage -
>>> pyeMaths.int_div(36, 3)
12
Exponent¶
Function Name - expo(num1, num2)
No. of Parameters - 2
Parameters - num1, num2
Usage -
>>> pyeMaths.expo(2, 4)
16
Modulus¶
Function Name - mod(num1, num2)
No. of Parameters - 2
Parameters - num1, num2
Usage -
>>> pyeMaths.mod(17, 2)
1
Evaluate Any Mathematics Expression¶
Function Name - eval_exp(exp)
No. of Parameters - 1
Parameters - exp
Usage -
>>> pyeMaths.expo('2 + 4 - 1 * 2')
10
Average¶
Function Name - avg(listOfNos)
No. of Parameters - 1
Parameters - listOfNos
Usage -
>>> pyeMaths.avg(['2', '3', '1', '5', '8', '4', '3'])
3.7142857142857144
py_everything.requestsLib¶
Send a POST Request¶
Function Name - postR(apiUrl, data=None)
No. of Parameters - 2
Parameters - apiUrl, data
Send a PUT Request¶
Function Name - putR(apiUrl, data=None)
No. of Parameters - 2
Parameters - apiUrl, data
Send a PATCH Request¶
Function Name - patchR(apiUrl, data=None)
No. of Parameters - 2
Parameters - apiUrl, data
Get Content from a Response¶
Function Name - getContent(response)
No. of Parameters - 1
Parameters - response
Get Text from a Response¶
Function Name - getText(response)
No. of Parameters - 1
Parameters - response
Get JSON from a Response¶
Function Name - getJson(response)
No. of Parameters - 1
Parameters - response
Get Headers from a Response¶
Function Name - getHeader(response)
No. of Parameters - 1
Parameters - response
Get a Specific Header from a Response¶
Function Name - getSpecificHeader(response, headerName)
No. of Parameters - 2
Parameters - response, headerName
py_everything.search¶
Search Files¶
Function Name - search_files(keyword, path)
No. of Parameters - 2
Parameters - keyword, path
Usage -¶
>>> pyeSearch.search_files("mykeyword", "D:")
['D:\mykeyword.txt', 'D:\file-with-mykeyword.pdf', 'D:\myfolder\pymykeyword.py']
This function searches for files with keyword
in them in path
.
And returns a list containing the full path of those files.
Search Folders¶
Function Name - search_dirs(keyword, path)
No. of Parameters - 2
Parameters - keyword, path
Usage -¶
>>> pyeSearch.search_dirs("myfolder", "D:")
['D:\folder\myfolder', 'D:\myfolder-py']
This function searches for folders or directories with keyword
in
them in path
. And returns a list containing the full path of those
folders or directories.
Search by Extension¶
Function Name - search_exts(ext, path)
No. of Parameters - 2
Parameters - ext, path
Usage -¶
>>> pyeSearch.search_exts("txt", "D:")
['D:\folder\file.txt', 'D:\py.txt']
This function searches for files with the extension ext
in path
.
And returns a list containing the full path of those files.
Search in Lists¶
Function Name - search_list(listOfTerms, query, filter=’in’)
No. of Parameters - 3
Parameters - listOfTerms, query, filter
Usage -¶
>>> mylist = ["python", "pipypi", "py", "endpy", "other", "file", "everything"]
>>> pyeSearch.search_list(mylist, "py", filter="in")
['python', 'pipypi', 'py', 'endpy']
>>> pyeSearch.search_list(mylist, "py", filter="start")
['python', 'py']
>>> pyeSearch.search_list(mylist, "py", filter="end")
['endpy']
>>> pyeSearch.search_list(mylist, "py", filter="exact")
['py']
This function searches for items with query
in them in
listOfItem
. And returns a list containing the items. filter
can
have 4 values, i.e., ‘in’, ‘start’, ‘end’, ‘exact’. ‘in’ returns items
which have query
in them. ‘start’ returns items which start with
query
. ‘end’ returns items which end with query
. ‘exact’ returns
items which are exactly the query
.
py_everything.web¶
Search Google¶
Function Name - google_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.google_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Google for query
.
Search Youtube¶
Function Name - yt_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.yt_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches YouTube for query
.
Search GitHub¶
Function Name - github_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.github_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches GitHub for query
.
Search Stack Overflow¶
Function Name - so_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.so_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Stack Overflow for query
.
Search Amazon.in¶
Function Name - amz_in_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.amz_in_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Amazon.in for query
.
Search Amazon.com¶
Function Name - amz_com_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.amz_com_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Amazon.com for query
.
Search PyPI¶
Function Name - pypi_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.pypi_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches PyPI for query
.
Search Read The Docs¶
Function Name - rtdocs_search(query)
No. of Parameters - 1
Parameters - query
Usage -¶
>>> pyeWeb.rtdocs_search("py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Read the Docs for query
.
Search in a New Tab¶
Function Name - open_new_tab(url, query)
No. of Parameters - 2
Parameters - url, query
Usage -¶
>>> google_url = 'https://google.com/search?q='
>>> pyeWeb.open_new_tab(google_url, "py_everything")
<--It opens a tab in your browser and shows the results-->
This function searches Google for query
in a new tab.
Search in a New Window¶
Function Name - open_new_window(url, query)
No. of Parameters - 2
Parameters - url, query
Usage -¶
>>> gh_url = 'https://github.com/search?q='
>>> pyeWeb.open_new_window(gh_url, "py_everything")
<--It opens a window in your browser and shows the results-->
This function searches GitHub for query
in a new window.
- … toctree::
- caption
Basic:
Dependencies and Dependents¶
py_everything depends on -¶
License¶
MIT License
Copyright (c) 2021 py_everything
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.