diff --git a/README.md b/README.md index 98843ea..b4887d3 100644 --- a/README.md +++ b/README.md @@ -42,39 +42,39 @@ List of Functions: ------------------ -| | | -|----------------------------------------------------------|--------------------------------------------------------------------------------------------------| -| p() | print() function. | -| repeat(function,n) | Repeat F_Name function for n times. | -| rev(v) (REMOVED 2.4.0) | Reverse v and returns it. (Everything like str,list,int) | -| read(file) | Return content of the file. | -| write(file,mode,text) | Write things you want in file content. (Read Doc String) | -| wait(n)sleep(n) | Stop code executing for n seconds | -| cls()clear() | It Clears the Terminal | -| progressbar() (*removed in v3.1) | In-App Progressbar. (Read Doc String) | -| cons_integer(Frst,Lst) | Return string from Frst to Lst (Read Doc String) (v1.7) | -| force(tpl,*var) | Return tpl with adding var(s) to it. | -| erase(tpl,*var) | Return tpl with removing var(s) from it. | -| replace(tpl,ind,var) | Replace tpl[ind] with var | -| insert(tpl,ind,var) | Set tpl[ind] to var. (Note that tpl[ind] will be tpl[ind+1]) | -| pop(tpl,index) | Remove member with index of 'index' from a tuple | -| wait_for(button) | Waits for user to press specific button. | -| call_later(func,args,delay) | Call func(args) after delay time. | -| convert_bytes(num) | convert bytes to (KB,MB,GB,TB) | -| Input(prompt,default) | Prompt an input message with default answer (value) (ONLY ON WINDOWS) | -| default_input() | Same as `default_input` | -| restart_app() | Restart running python program | -| active_window_title() | Return Active Window Title | -| open_image(path) | Open image with default image viewer (Mac OS is not supported) | -| download(url) | To download files with memory saver and progressbar | -| extract(file,path,pwd) | Extract Zip file with password to path | -| screenshot(name) | Take a screenshot and save it. | -| func_info(function) | Print information of function | -| Check_Type | Decorator that raise TypeError if function argument type is wrong (Read Help) | -| Progressbar() | Generator of progressbar() which you can use it to do some stuff between your delays (Read Help) | -| pixel_color(X,Y) | Return RGB color of pixel[X,Y] | -| getpass(prompt) | Prompt for a password, with echo turned off. | -| import_module(path) | Return given path (file with any extension) as a Module | +| | | +|----------------------------------|--------------------------------------------------------------------------------------------------| +| p() | print() function. | +| repeat(function,n) | Repeat F_Name function for n times. | +| rev(v) (REMOVED 2.4.0) | Reverse v and returns it. (Everything like str,list,int) | +| read(file) | Return content of the file. | +| write(file,mode,text) | Write things you want in file content. (Read Doc String) | +| wait(n)sleep(n) | Stop code executing for n seconds | +| cls()clear() | It Clears the Terminal | +| progressbar() (*removed in v3.1) | In-App Progressbar. (Read Doc String) | +| cons_integer(Frst,Lst) | Return string from Frst to Lst (Read Doc String) (v1.7) | +| force(tpl,*var) | Return tpl with adding var(s) to it. | +| erase(tpl,*var) | Return tpl with removing var(s) from it. | +| replace(tpl,ind,var) | Replace tpl[ind] with var | +| insert(tpl,ind,var) | Set tpl[ind] to var. (Note that tpl[ind] will be tpl[ind+1]) | +| pop(tpl,index) | Remove member with index of 'index' from a tuple | +| wait_for(button) | Waits for user to press specific button. | +| call_later(func,args,delay) | Call func(args) after delay time. | +| convert_bytes(num) | convert bytes to (KB,MB,GB,TB) | +| Input(prompt,default) | Prompt an input message with default answer (value) (ONLY ON WINDOWS) | +| default_input() | Same as `default_input` | +| restart_app() | Restart running python program | +| active_window_title() | Return Active Window Title | +| open_image(path) | Open image with default image viewer (Mac OS is not supported) | +| download(url) | To download files with memory saver and progressbar | +| extract(file,path,pwd) | Extract Zip file with password to path | +| screenshot(name) | Take a screenshot and save it. | +| func_info(function) | Print information of function | +| Check_Type | Decorator that raise TypeError if function argument type is wrong (Read Help) | +| Progressbar() | Generator of progressbar() which you can use it to do some stuff between your delays (Read Help) | +| pixel_color(X,Y) | Return RGB color of pixel[X,Y] | +| getpass(prompt) | Prompt for a password, with echo turned off. | +| import_module(path) | Return given path (file with any extension) as a Module |
@@ -97,30 +97,31 @@ List of Functions:

  Class System:   Some system actions and information.

-| | | -|-------------------------------|----------------------------------------------------------------------------------| -| accname() | return account username you have logged in. | -| pid() | Get pid number of terminal and return it. | -| disk_usage(path) | ######## | -| chdir | Change directory of terminal. | -| SHUT_DOWN() | Shut Down the PC. | -| RESTART() | Restart the PC. | -| terminal_size() | Return terminal size in tuple (columns,lines). | -| cwd() | Return Carrent Working Directory. | -| ip_global() | Returns Global IP. | -| ip_local() | Returns Local IP. | -| ram_total() | Returns total ram of the system. | -| ram_used() | Returns Used Space of the ram of the system. | -| ram_free() | Returns Available (Free) space of system ram. | -| boot_time() | Return system boot time in seconds since the epoch. | -| device_name() | Returns Device Name | -| ip_website(url) | Returns url ip address | -| win10_notification() | Display windows 10 notification (READ DOCSTRING) (ONLY WIN10 SUPPORTED) | -| cpu_count(logical=True) | Return the number of logical/physical CPUs in the system | -| pyshell_execute_bit() | To determine whether Python shell is executing in 32bit or 64bit | -| pids() | Return a list of current running PIDs | -| pid_exists(pid) | Return True if pid exists else False | -| cpu_percent() | Return the current CPU utilization as a percentage | +| | | +|-------------------------|-------------------------------------------------------------------------| +| accname() | return account username you have logged in. | +| pid() | Get pid number of terminal and return it. | +| disk_usage(path) | ######## | +| chdir | Change directory of terminal. | +| SHUT_DOWN() | Shut Down the PC. | +| RESTART() | Restart the PC. | +| terminal_size() | Return terminal size in tuple (columns,lines). | +| cwd() | Return Carrent Working Directory. | +| ip_global() | Returns Global IP. | +| ip_local() | Returns Local IP. | +| ram_total() | Returns total ram of the system. | +| ram_used() | Returns Used Space of the ram of the system. | +| ram_free() | Returns Available (Free) space of system ram. | +| boot_time() | Return system boot time in seconds since the epoch. | +| device_name() | Returns Device Name | +| ip_website(url) | Returns url ip address | +| win10_notification() | Display windows 10 notification (READ DOCSTRING) (ONLY WIN10 SUPPORTED) | +| cpu_count(logical=True) | Return the number of logical/physical CPUs in the system | +| pyshell_execute_bit() | To determine whether Python shell is executing in 32bit or 64bit | +| pids() | Return a list of current running PIDs | +| pid_exists(pid) | Return True if pid exists else False | +| cpu_percent() | Return the current CPU utilization as a percentage | +| os_name() | Returns OS name of machine | @@ -129,38 +130,41 @@ List of Functions:

  Class Files: (Static methods) Actions and information about files.

-| METHOD | DESCRIPTION | -|---------------------------------------------------------------|-------------------------------------------------------------------------------| -| size(path) | Return size of the file in byte(s). Also work on | -| delete(path) | Use this to delete a file (Not folder). | -| rename(path) | Rename files with this function. | -| abspath(path) | Return absolute path of given path. | -| exists(path) | Return Boolean. If exists True, else: False | -| mdftime(path) | Get last modify time of the file. | -| acstime(path) | Get last access time of the file. | -| move(src,dst) | Move file from src to dst. (Read Doc String of copy func) | -| copy(src,dst,metadata=True) | Copy file (with metadata) from src to dst. (Also work on folders) | -| hide(path) | Hide given path. (It can be file or directory.) | -| read_only(path,mode=True) | Make file or folder read-only. (Read Doc String) | -| read(path) | Return content of the path | -| write(path,text='',...) | Same as write function. | -| isdir(path) | Return True for directory and False for others. | -| isfile(path) | Return True for file and False for others. | -| is_hidden(path) | Check whether path is hidden or not | -| is_readonly(path) | Check whether path is readonly or not | -| search_file(pattern,path,mode) | search for pattern in path (Read function doc string) | -| search_content(path,word) | Search for word in all files in path, return list of files that contain word | -| mkdir(path) | Make directory (More than one if its possible!) | -| generate_tree(dir_path) | Returns a visual tree of dir_path | -| get_drives() | (Windows only) Get currently available drives | -|         MEMBERS (Family) | | -| MEMBERS.all_exactdir | List of all things those are in exact directory | -| MEMBERS.files_exactdir | List of files which are in exact directory | -| MEMBERS.dirs_exactdir | List of dirs which are in exact directory | -| MEMBERS.files_all | List of files which are in exact directory and all sub-directories | -| MEMBERS.files_all_sep | List of files which are in exact directory and all sub-directories seprated by their directories | -| MEMBERS.dirs_all | List of directories (Exact dir and all sub-dirs) | -| MEMBERS.all_all_sep | List of everything thing in path (exact dir & sub-dirs) | +| METHOD | DESCRIPTION | +|----------------------------------------------|-------------------------------------------------------------------------------| +| size(path) | Return size of the file in byte(s). Also work on | +| delete(path) | Use this to delete a file (Not folder). | +| rename(path) | Rename files with this function. | +| abspath(path) | Return absolute path of given path. | +| exists(path) | Return Boolean. If exists True, else: False | +| mdftime(path) | Get last modify time of the file. | +| acstime(path) | Get last access time of the file. | +| move(src,dst) | Move file from src to dst. (Read Doc String of copy func) | +| copy(src,dst,metadata=True) | Copy file (with metadata) from src to dst. (Also work on folders) | +| hide(path) | Hide given path. (It can be file or directory.) | +| read_only(path,mode=True) | Make file or folder read-only. (Read Doc String) | +| read(path) | Return content of the path | +| write(path,text='',...) | Same as write function. | +| isdir(path) | Return True for directory and False for others. | +| isfile(path) | Return True for file and False for others. | +| is_hidden(path) | Check whether path is hidden or not | +| is_readonly(path) | Check whether path is readonly or not | +| search_file(pattern,path,mode) | search for pattern in path (Read function doc string) | +| search_content(path,word) | Search for word in all files in path, return list of files that contain word | +| mkdir(path) | Make directory (More than one if its possible!) | +| generate_tree(dir_path) | Returns a visual tree of dir_path | +| get_drives() | (Windows only) Get currently available drives | +| basename(path) | Returns the final component of a pathname | +| dirname(path) | Returns the directory component of a pathname | +| join_paths(path) | Joins multiple paths together and returns it | +|         MEMBERS (Family) | | +| MEMBERS.all_exactdir | List of all things those are in exact directory | +| MEMBERS.files_exactdir | List of files which are in exact directory | +| MEMBERS.dirs_exactdir | List of dirs which are in exact directory | +| MEMBERS.files_all | List of files which are in exact directory and all sub-directories | +| MEMBERS.files_all_sep | List of files which are in exact directory and all sub-directories seprated by their directories | +| MEMBERS.dirs_all | List of directories (Exact dir and all sub-dirs) | +| MEMBERS.all_all_sep | List of everything thing in path (exact dir & sub-dirs) |
@@ -168,13 +172,13 @@ List of Functions:

  Class Style:    Changing text Color,BG & Style. (Read Doc String)

-| | | -|---------------------------------------------------------|-------------------------------------------------------------| -| print\(\*values, color, BG, style, end, sep\) | Print txt with selected color,BG,style\.\(Read Doc String\) | -| switch\(color,BG,style\) | Change Terminal Attributes Until another Call\. | -| switch\_default\(\) | Restore Terminal Attributes\. | -| reset | =switch\_default | -| log\_  \(Family\) | 5 Different Style\.print with ready color and style | +| | | +|-----------------------------------------------|-------------------------------------------------------------| +| print\(\*values, color, BG, style, end, sep\) | Print txt with selected color,BG,style\.\(Read Doc String\) | +| switch\(color,BG,style\) | Change Terminal Attributes Until another Call\. | +| switch\_default\(\) | Restore Terminal Attributes\. | +| reset | =switch\_default | +| log\_  \(Family\) | 5 Different Style\.print with ready color and style |
@@ -182,15 +186,16 @@ List of Functions:

  Class Record:   Record time of a certain actions. (Read Doc String)

-| | | -|---------------------------------------------------------------------|----------------------------------------------------------------------------| -| __init__() | Set Start Time. | -| self.stop(self) | Stops Recording (You can not lap anymore) | -| self.lap(self, save=True, round=15) | Rreturn time between start time. if save==True: add that time to self.laps | -| self.laps | A list that contains all laps you have done | -| self.reset(self, start=False) | Empty self.laps, if start is True: set start time to now | -| self.last_lap(save=True) | Return elapsed time from last lap (save it in self.laps if save is true) | -| timeit(code,setup, times,globals_) | Run the 'code' for 'times' times and return time it needs (all, not once) | +| | | +|-------------------------------------|----------------------------------------------------------------------------| +| __init__() | Set Start Time. | +| self.stop(self) | Stops Recording (You can not lap anymore) | +| self.lap(self, save=True, round=15) | Rreturn time between start time. if save==True: add that time to self.laps | +| self.laps | A list that contains all laps you have done | +| self.reset(self, start=False) | Empty self.laps, if start is True: set start time to now | +| self.last_lap(save=True) | Return elapsed time from last lap (save it in self.laps if save is true) | +| timeit(code,setup, times,globals_) | Run the 'code' for 'times' times and return time it needs (all, not once) | +| timer(f) | Decorator for functions to print out how much each call takes |
@@ -280,6 +285,20 @@ Releases and Changelog: New Features & Changes + + +

3.3.0

+ + 29/04/2023 + +
+ Files.basename()
+
+ Files.dirname()
+
+ Files.join_paths()
+
* `pre_action` and `post_action` in IO selective_input
+
+ Record.timer decorator
+
+ System.os_name()
+ + @@ -288,7 +307,7 @@ Releases and Changelog: 10/03/2023
+ `environ` variable: environment variables as a dict
-
+ `Terminal.get_size()`
+
+ `Terminal.size()`
+ `exit()`: sys.exit()
+ `files.get_drives()`
+ IO.selective_input `choices` argument upgrade
diff --git a/rx7/__init__.py b/rx7/__init__.py index 3166588..c7ccd92 100644 --- a/rx7/__init__.py +++ b/rx7/__init__.py @@ -12,17 +12,12 @@ Written By RX Last Update: 04-28-2022 ''' -__version__ = '3.2.0' +__version__ = '3.3.0' """ < Release Changes > -+ Files.basename() -+ Files.dirname() -+ Files.join_paths() -+ `pre_action` and `post_action` in IO.selective_input -+ Record.timer decorator """ @@ -672,25 +667,27 @@ class Files: (READ FUNCTIONS DOCSTRING) GET INFORMATION: - - exists() - - size() - - abspath() - - mdftime() - - acstime() - - content (read function)() - - is file() - - is dir() - - is readonly() - - is hidden() + - exists + - size + - abspath + - mdftime + - acstime + - basename + - dirname + - content + - is_file + - is_dir + - is_readonly + - is_hidden ACTIONS: - - remove() - - rename() - - move() - - copy() - - hide() - - read only() - - write() + - remove + - rename + - move + - copy + - hide + - read only + - write ''' @staticmethod def size(path:str) -> int: @@ -795,7 +792,7 @@ def copy(src:str, dest:str, preserve_metadata:bool=True) -> None: def hide(path:str, mode:bool=True) -> None: ''' Hide file or folder. - If mode==False: makes 'not hide' + If mode==False: unhides the file/folder (WINDOWS ONLY) ''' try: @@ -986,6 +983,7 @@ def get_drives() -> tuple: @staticmethod def basename(path:str) -> str: + """Returns the final component of a pathname""" return _os.path.basename(path) @staticmethod @@ -994,6 +992,7 @@ def join_paths(path:str, *paths) -> str: @staticmethod def dirname(path:str) -> str: + """Returns the directory component of a pathname""" return _os.path.dirname(path) class MEMBERS: diff --git a/setup.py b/setup.py index 2b6336c..7b3f310 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ s = setup( name = "rx7", - version = "3.2.0", + version = "3.3.0", license = "LGPL", description = "Shortcut for most usefull functions, High API, Special Features", url = "https://github.com/Ramin-RX7/RX7-Lib",