Skip to main content

Shortcut for most usefull functions, High API, Special Features

Project description

PyPI - License PyPI - License PyPI - License

Version 2.0.0 Out Now!

rx7 Library  is here to help you make your code shorter!

- High API

- Special Features

- Most Usefull function and methods are collected.

 

 Are you tired of importing lots of module in one script? rx7 can help you a lot

 

 

List of Functions:

p() print() function. (Read Doc String)
repeat(function,n) Repeat F_Name function for n times.
rev(v) 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) Stop code executing for n seconds
cls() It Clears the Terminal
progressbar() 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])
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) 
restart_app()
Restart running python program
active_window_title()
Return Active Window Title
open_image()
Open image with default image viewer (Mac OS is not supported)

 

List of Classes:

 Class rand:   Random Variable Generator Class.

choose(iter,k,duplicate) Choose k random items from iterable or string.
integer(Frst,Lst) Choose integer in range [Frst,Lst]
O1(decimal_nom=17) Return x in interval [0,1)
number(Frst,Lst) Return x in interval [Frst,Lst]

 

  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

 

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

size(path)
Return size of the file in byte(s). Also work on directories.
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

 

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

print(txt,clr,BG,style,end)
(from v1.5.0)

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.

 

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

__init__() Set Start Time.
self.stop() Stops Recording (You can not lap anymore)
self.lap(save=True) 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(start=False) Empty self.laps, if start is True: set start time to now

 

 

List of Objects:

    object File: Actions and information about files.

__init__(self,path) Creating file object.
self.size
size of the file in byte(s). Also work on directories.
self.abspath
Return absolute path of given path.
self.exists Return Boolean. If exists True, else: False
self.mdftime
Get last modify time of the file.
self.acstime
Get last access time of the file.
self.type
'file' for files and 'dir' for directories.
self.delete()
Use this to delete file or folder.
self.rename(new_name)
Rename file with this method.
self.move(dst) Move file from path to dst. (Read Doc String of copy func)
self.copy(dst) Copy file from self.path to dst. (Also you can use it as rename)
self.hide(path) Hide given path. (It can be file or directory.)
self.read_only(mode=True) Make file or folder read-only. (Read Doc String)
self.content  (only for files) If self.type=='file': content is files.read(self.path)
self.basename  (only for files) Basename of file (e.g: C:/Users/file.txt ==> file.txt) 
self.ext  (only for files) Returns File extension if it has else None
   
    if self.path is dir  
self.tree String which presents visual tree from path to the end.
self.tree_dirs String which presents visual tree from path to the end. (Only directories)
self.MEMBERS.
all_exactdir
List of all things those are in exact directory
self.MEMBERS.files_exactdir
List of files which are in exact directory
self.MEMBERS.dirs_exactdir
List of dirs  which are in exact directory
self.MEMBERS.files_all List of files which are in exact directory and all sub-directories
self.MEMBERS.
files_all_sep
List of files which are in exact directory and all sub-directories seprated by their directories
self.MEMBERS.dirs_all
List of directories (Exact dir and all sub-dirs
self.MEMBERS.all_all_sep List  of all things in path (exact dir & sub-dirs)

 

     object Tuple: It's like built-in tuple except it's faster and it has more features!

         Descryption:

            Tuple is here with built-in tuple object and much more features.

            You can add, remove, replace or even use __setitem__ Tuple object.

            I recommend using tuple= rx.Tuple that can make it relay easier for you o work.

         Supports:   indexing - len - hash  - bool - __add__ 

Tuple(*var,one=False) Create Tuple object with *var members
self.add(*vars) Add *vars to self
self.force(*vars) self.add
self.remove(*vars) Remove *vars from self (Ignore it if it's not in self).
self.erase(*vars) self.remove
self.replace(ind,var) Replace self[index] with var. (index can be int or anything thats in self
self[index]=var Set self[index] to var. (Like lists) (it does not replace)

 

     object RX_obj: It's an object with so many featues. (More features in upcoming updates!)

              Description:

                 It's a kind of object that I will improve it in upcoming updates (If only you guys like it).

                 You can use: MyCustomName= rx.RX_obj  so you can access it easier.

                 One special feature it has is 'lock'. When you lock the object you can't add or remove anything to it. Also You can not delete it! Doing these will raise LockError.

                 using self.lock_error= False  can stop raising error when adding or removing (Not deleting) (But it doesn't mean it will add things to it. It just ignores errors)

           Supports:   indexing - len - hash  - bool - __add__ - __sub__ - lock 

RX_obj(*var,one=False) Create RX_obj object with *var members
self.ND self members without duplicate. (set of self members)
self.lock() Make self locked (You can not add or remove. You can't delete self)
self.unlock() Unlock self
self.lock_error= True (boolean) If self.lock_error is False, It doesn't raise error when adding or removing things to self.
self.add(*vars) Add *vars to self
self.remove(*vars) Remove *vars from self (Ignore it if it's not in self).
self.replace(ind,var) Replace self[index] with var. (index can be int or anything thats in self
self[index]=var Set self[index] to var. (Like lists) (it does not replace)
self.  

 

 

 

 

Recommended to:

  - Using an IDE that shows Function and Class Help is highly recommended.  (VS Code - PyCharm)

 - Using "from rx7 import FUNC_or_CLASS"

 - Using "import rx7 as rx"

 

 Upgrade:

               pip install --upgrade rx7

 Use These Commands in Terminal:

               $ rx7 color           (To show help for style class)

               $ rx7 help            (To open this page that contains help)

 

Versions Information:

        Releases are like this:        1.0.0

                                                1.1.1

                                                   â‹®

                                                1.2.0

        First number is very important bacause it's for Realy Big new features and changes.

        Second number is important but not like first number because it contains some changes and new features. (RECOMMENDED for upgrading package)

        But 3rd number is not important because it's for changing packege codes order and you won't lose anything if you        don't install it.

        Numbers are not always in order like: 1,2,3,4,...  , Some times they are different like: 1.2.4.8,...

 

Releases:

         (+ for new features, * for changes)

Version Release Date New Features & Changes

2.1.0

15/07/2020

* style class better performance in linux

MEMBERS group in files class

+ File object:  self.basename, self.ext

+ system.device_name()

active_window_title() --- open_image()

2.0.0

01/07/2020

+ Tuple object   ---   rxobject

+ record.reset()   ---   record.lap new arg

+ New methods of files

      files.is_readonly()   ---   files.is_hidden()

      files.search_file()   ---   files.search_content()

      files.copy new arg

      files.generate_tree()

+ File.MEMBERS (when in File(path), path is a directory  (self.MEMBERS.TYPE_PATH)

+ File.tree    ---     File.tree_dirs

+ Input()  (Only on windows)

+ restart_app()

 

1.9.0   09/06/2020

* re() --> repeat()

+ New Methods of System Class:  ip_global(), ip_local(), ram_free(), ram_percent(), ram_total(), ram_used(), boot_time()

+ convert_bytes()

1.8.0 05/24/2020
+ style.switch_default()
+ Now Linux supports cls()
+ style object: supports multiply,add,index
+ rand.choice Choose >1 & duplicate
* rand.choice --> rand.choose
1.7.0   05/08/2020
+ call_later()  -  wait_for()
+ terminal_size()  -  cwd()
+ right_port,left_port arg for progressbar()
+ file.remove() for static usage
+ self.type in file class
+ if in file(x), x is a directory:
x.files , x.file_list , x.all_files , x.all_files_sep
+ file.isdir() , file.isfile() for static usage.
* string() => cons_int()
* progressbar() arg names
* file.delete() and file.delete_dir() => delete()
* Change replace() and insert() args oreder
1.5.0 04/21/2020
+ 'replace' and insert 'functions' for tuples
+ 'end' arg for style.print()
+ 'self.laps' in record class will display all laps
* style.text => style.print
* record.stop => record.lap
* now 'record.stop()' will stop recording.
1.3.0  04/08/2020
+ __init__ & read & write & content  func of file class
* Prgoressbar default args

1.0.0

03/18/2020

####

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rx7-2.1.0.tar.gz (36.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page