From 57e3971eaab3405b88a0189e585aaab2b950567e Mon Sep 17 00:00:00 2001 From: Prayag Jain Date: Fri, 5 Mar 2021 21:12:46 +0530 Subject: [PATCH] ADDED TO PYPI! FINALLY! --- .gitignore | 6 +- README.md | 11 +-- install.sh | 20 ----- konsave/__init__.py | 0 konsave/__main__.py | 46 +++++++++++ konsave/__pycache__/__init__.cpython-39.pyc | Bin 0 -> 162 bytes konsave/__pycache__/__main__.cpython-39.pyc | Bin 0 -> 1432 bytes konsave/__pycache__/funcs.cpython-39.pyc | Bin 0 -> 6080 bytes konsave/__pycache__/vars.cpython-39.pyc | Bin 0 -> 851 bytes konsave => konsave/funcs.py | 87 ++++---------------- konsave/vars.py | 19 +++++ setup.py | 29 +++++++ 12 files changed, 116 insertions(+), 102 deletions(-) delete mode 100755 install.sh create mode 100644 konsave/__init__.py create mode 100755 konsave/__main__.py create mode 100644 konsave/__pycache__/__init__.cpython-39.pyc create mode 100644 konsave/__pycache__/__main__.cpython-39.pyc create mode 100644 konsave/__pycache__/funcs.cpython-39.pyc create mode 100644 konsave/__pycache__/vars.cpython-39.pyc rename konsave => konsave/funcs.py (70%) mode change 100755 => 100644 create mode 100644 konsave/vars.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 42061c0..b9b1072 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ -README.md \ No newline at end of file +README.md +env +Konsave.egg-info +build +dist \ No newline at end of file diff --git a/README.md b/README.md index 8434b41..f004bd1 100644 --- a/README.md +++ b/README.md @@ -7,16 +7,11 @@ A CLI program that will let you save and apply your KDE Plasma customizations wi --- ## Dependencies -There are no dependencies! Just make sure your python version is above `3.8`. +There are no dependencies! Just make sure your python version is above `3.9`. ## Installation -- Clone This repo -`git clone https://github.com/Prayag2/konsave ~/Downloads/konsave` -- Make it executable -`cd ~/Downloads/konsave` -`chmod +x ./install.sh` -- Install -`./install.sh` +Install from PyPI +`python -m pip install konsave` ## Usage ### Get Help diff --git a/install.sh b/install.sh deleted file mode 100755 index 47013be..0000000 --- a/install.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# Print intro -echo '~~~~~~~~~~~~~~~~~~~~~~~~~~~ - _ ___ __ -| | | \ \/ / Prayag Jain | Hax Guru -| |_| |\ / YouTube: https://youtube.com/c/haxguru -| _ |/ \ GitHub: https://github.com/Prayag2 -|_| |_/_/\_\ Email: prayagjain2@gmail.com - -~~~~~~~~~~~~~~~~~~~~~~~~~~~' -echo 'Installing konsave...' - -# Copy 'konsave' to ~/.local/bin/ -mkdir -p ~/.local/bin -cp ./konsave ~/.local/bin -chmod +x ~/.local/bin/konsave - -# Done -echo 'Installed successfully! You can now delete this folder.' -echo "Try 'konsave -h' for more info!" diff --git a/konsave/__init__.py b/konsave/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/konsave/__main__.py b/konsave/__main__.py new file mode 100755 index 0000000..2fb014b --- /dev/null +++ b/konsave/__main__.py @@ -0,0 +1,46 @@ +## IMPORT ## +import os, argparse +from konsave.funcs import * + + +## MAIN ## +def main(): + + ## PARSER SETTINGS ## + parser = argparse.ArgumentParser( + prog = 'Konsave', + epilog = "Please report bugs at https://www.github.com/prayag2/konsave" + ) + + ## ADDING ARGS ## + parser.add_argument('-l', '--list', required = False, action = 'store_true', help='Lists created profiles') + parser.add_argument('-s', '--save', required = False, type = str, help='Save current config as a profile', metavar = '') + parser.add_argument('-r', '--remove', required = False, type = int, help='Remove the specified profile', metavar = '') + parser.add_argument('-a', '--apply', required = False, type = int, help='Apply the specified profile', metavar = '') + parser.add_argument('-e', '--export-profile', required = False, type = int, help='Export a profile and share with your friends!', metavar = '') + parser.add_argument('-i', '--import-profile', required = False, type = str, help='Import a konsave file', metavar = '') + + ## PARSING ARGS ## + args = parser.parse_args() + + ## CHECKING FOR ARGUMENTS ## + if args.list: + check_error(list_profiles, list_of_profiles, length_of_lop) + elif args.save != None: + check_error(save_profile, args.save, list_of_profiles) + elif args.remove != None: + check_error(remove_profile, args.remove, list_of_profiles, length_of_lop) + elif args.apply != None: + check_error(apply_profile, args.apply, list_of_profiles, length_of_lop) + elif args.export_profile != None: + check_error(export, args.export_profile, list_of_profiles, length_of_lop) + elif args.import_profile != None: + check_error(import_profile, args.import_profile) + else: + parser.print_help() + + + +## CALLING MAIN ## +if __name__ == '__main__': + main() diff --git a/konsave/__pycache__/__init__.cpython-39.pyc b/konsave/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..590f9376a57a824fa04e81aacfd3c3a3d8765f10 GIT binary patch literal 162 zcmYe~<>g`k0uOJe1Q7igL?8o3AjbiSi&=m~3PUi1CZpd~wiuD63OEU8F^t1ExiWAFHG3faC%)HE!_;|g7%3B;Zx%nxjIjMFa J3qAue0|2~qC(Zx> literal 0 HcmV?d00001 diff --git a/konsave/__pycache__/__main__.cpython-39.pyc b/konsave/__pycache__/__main__.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b02593d1022e086d8c682d7a7e6f9b093e34f2e6 GIT binary patch literal 1432 zcmZ`(%Z}SN6eT5D)_82knOECn3aH(wfb1fRE`ouP2il@Y5e$;9gaRrf(voKMDoJNz zVX~TR2MF>7$+AGdqaVR#yXr4=5%iLN%nXXkATQ53yvO7vK{6Qh5PWZ+Jo;q{qrWt` z{#gJXKoj?%qln@HMazgI4A?5HpAfaF^9DsWb7<$(;$voCAPjS#qrm+e^3c-&EBsZW zhwD!pd(a+36OS-L5}ja*sYUHe>oqz@Cl&=e>e4Rt=+73*!>&q0sX|VpWa|Uqj!w&U3$27c;ESeUgL9o;_}~RS9)?w_AYFU zs&~L`Q*>(cKY;IRB)5$63dRGY{0YiXBa`Jo*3W=$8SNuzBaJrN13#D=b&WL2xhoo6vFcH|wXFO*W6<@&L<=P}KZs& zZWhYX!+rhgd<`9P9c*FiqwDVBgZ0n$Y!?r4509YjnAV5b$3u(jOy#W&gO0Ll!MA{n r2CH)%&*oJkHWT&zjbpQkYu%o)IVx*9FW6K+hC;uFBkb*XfrtMEHD#l+ literal 0 HcmV?d00001 diff --git a/konsave/__pycache__/funcs.cpython-39.pyc b/konsave/__pycache__/funcs.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3d13dbb15b59740dac38fa2ba4db05d971cc8dc4 GIT binary patch literal 6080 zcmb7ITXWmS6~>Jqco9WiY)iJsMbgGLJuwwKPA7F8*NQABie*Y8$+>XSvJ4jzA&~^L zSjrX#%0rYsru_k#%t$kRXr}+5FZ~~Q?Nk1O`jCESmp3V%PD>7Uv1hSZ?6>E9=bWui zOk_3u-dKJAkI%1Y+P|nV{xi^cgeyEo!8E3~w5qE0sxI3`)sVGWHBlQatDUN*bb7{Y z+3j>S-FB*uY+J3&mc~-d{zj{2S(-Vhb1cKMsPinx@~9`+1S_B}ut`=#J;|onH0mOo zVY8^G*adbG^)$Q0=1|YDd3G7~EYml&(v=_am0G2wC+V=++um+@B_qlDVJ-5z+kVSS z(pA6v1UGm>ztzy`>Hd%IOUF@i9$x^>Y^Y$*>Dr(NIkFg7gdJdGKD z&^T?z>EnfF(DoL(ynayMSy&%b!7e5V7uF9%Gw3Yr1)Z?I@BOUa?sXbrxqFbL+Ix7n zL(8#IXjWd&>O7CT2CZ}Ovv4z9_v>iTx|z<5Z}menHWdO`w;Aj6T5QbI`pu{!SGCpj zLzgBLe$a7W_^p=Pt@F@x8$oB=-*E}@(5-iv8+vu#Xu8`0cf+pN@VEVjyI*hhyimUA z3HHMd1@{}GWF~nvT)v7Y`6cVh3GStC12$RphXuWI|0} zQ@urq#vz$SyMgP>ZwSdnh_U^EgtlK8%s4{LOu%48)AH*#yinA+P)msxx~+QHu7^zz zaNNGlJ+vF1`_Nrr-u^%GF_1{>xI`+))mmzM%$tWaB=yj&tidm#K4UP{Ljym+6@G*w%Ewx)|5-aU zKG8b&ETDGqNY@TcU5l;?;1`?Ufgip%3BOOY&w$~f`IXrzsQNAKEvVP#0NJOnP%z%> zK$}JiM~c;GdX2r1><+8vfR3)tf$MP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=wZ?iqa^Ct7f*ApRG$q;ZLYNAd{76BdQsY$+%1r$GBv=Z{TAx zzDl3)jEV{suZp`13X4J1_)k0+Qc$YdE+WQjmSfBsMOgbyShoBRYa7-t{|1h;o?}Gm zf`U-Sv<}X8)QMvOT~(XtGH6S(PSXA3V}(5dSIzfTsl1PKNtqOK$>Eel$ip7R@VBT* zsh7+IWIQXWM$SJ*Y0{C&yux|V4p^_{JtQ{~UPa-;X%%(HbQ~vxe;)OuGw;keQ_g$; E0qNh>>i_@% literal 0 HcmV?d00001 diff --git a/konsave/__pycache__/vars.cpython-39.pyc b/konsave/__pycache__/vars.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..45b08ba109c55ab6de1be16d83d47f6db8e5f0c2 GIT binary patch literal 851 zcmZWnL2uJA6i(8lNz-;4NaGKHgnC$tfFnY%vB5N0r%mGEOYvei$>P|S?UuF&F8q;= z8-K}HPW%NdC`WqPH5ubU; zquz~w8<616M;(Vl+993007Y9Ckq}sS%eo{278f4r{_s%(J_g?-2}<1;eH!2Sx}@Ii zphZ6D-ws=ZcIYnM`R=1V;$L~A-fyVEJ6}gnK1@Cxuj4Eid{z}Ut_9b4K~W-=m{pAG zQM8T=Qy)Cfo^8O3d+;)QhT^jY=4RfYh+$*sXdh}3OqLZ_IqJ1yf>D**w9cD~%eirw z(1M9;%rtsfZ&4|f$>&D9-&iFjRSv2-=ML`HI#-l(Ci2<^`n7H}RSQSD^;eg&@BAF< zR{8p=WLP)&K&T?C3C%V%BUIN$$O9}Tqb_5z*@1+^4T2M73}^(MgHX@8_6Shl^+})z z*iNpYqBZn~60uwr)HThjqBLv;!CtLfxe^qjtmb+#dSC;gZ78uRZAzCCbF#n+BJC7x zcq1xq)1%4x$?5y)yVFbCKbxFiz5RUb$l&5~a&r3d_-eyuf)T2w95+8wcImRxMx$<1lM2$s3@9MG*Mg~-P4A~|JB)HW1XGx@-C#og^wd6F7H9q( zjZ4wcu~c}4i}A(16E`$BdVH}mrQqZ3CHl{|y=HP{lUI!(Fr?Q3=;}vcl5pVfv`>)u Mi5~_7KMhj @@ -110,6 +98,7 @@ def save_profile(name, list_of_profiles): print_msg('Profile saved successfully!') +# APPLY PROFILE def apply_profile(id, list_of_profiles, length_of_lop): ''' Applies profile of the given id @@ -129,6 +118,7 @@ def apply_profile(id, list_of_profiles, length_of_lop): restart_kde() +# REMOVE PROFILE def remove_profile(id, list_of_profiles, length_of_lop): ''' Removes the specified profile @@ -146,6 +136,7 @@ def remove_profile(id, list_of_profiles, length_of_lop): print_msg('removed profile successfully') +# EXPORT PROFILE def export(id, list_of_profiles, length_of_lop): ''' It will export the specified profile as a ".knsv" file in the home directory @@ -207,6 +198,7 @@ def check_path_and_copy(path1, path2, export_location, name): print_msg(f"Successfully exported to {EXPORT_PATH}{export_extension}") +# IMPORT PROFILE def import_profile(path): ''' This will import an exported profile @@ -214,9 +206,7 @@ def import_profile(path): # assert assert (is_zipfile(path) and path[-5:] == export_extension), "Not a valid konsave file" - - item = os.path.basename(path)[:-5] - + item = os.path.basename(path)[:-5] assert (not os.path.exists(os.path.join(PROFILES_DIR, item))), "A profile with this name already exists" # run @@ -248,53 +238,4 @@ def import_profile(path): shutil.rmtree(TEMP_PATH) - print_msg("Profile successfully imported!") - - -## MAIN ## -def main(): - - ## VARIABLES ## - mkdir(PROFILES_DIR) - list_of_profiles = os.listdir(PROFILES_DIR) - length_of_lop = len(list_of_profiles) - - - ## PARSER SETTINGS ## - parser = argparse.ArgumentParser( - prog = 'Konsave', - epilog = "Please report bugs at https://www.github.com/prayag2/konsave" - ) - - ## ADDING ARGS ## - parser.add_argument('-l', '--list', required = False, action = 'store_true', help='Lists created profiles') - parser.add_argument('-s', '--save', required = False, type = str, help='Save current config as a profile', metavar = '') - parser.add_argument('-r', '--remove', required = False, type = int, help='Remove the specified profile', metavar = '') - parser.add_argument('-a', '--apply', required = False, type = int, help='Apply the specified profile', metavar = '') - parser.add_argument('-e', '--export-profile', required = False, type = int, help='Export a profile and share with your friends!', metavar = '') - parser.add_argument('-i', '--import-profile', required = False, type = str, help='Import a konsave file', metavar = '') - - ## PARSING ARGS ## - args = parser.parse_args() - - ## CHECKING FOR ARGUMENTS ## - if args.list: - check_error(list_profiles, list_of_profiles, length_of_lop) - elif args.save != None: - check_error(save_profile, args.save, list_of_profiles) - elif args.remove != None: - check_error(remove_profile, args.remove, list_of_profiles, length_of_lop) - elif args.apply != None: - check_error(apply_profile, args.apply, list_of_profiles, length_of_lop) - elif args.export_profile != None: - check_error(export, args.export_profile, list_of_profiles, length_of_lop) - elif args.import_profile != None: - check_error(import_profile, args.import_profile) - else: - parser.print_help() - - - -## CALLING MAIN ## -if __name__ == '__main__': - main() + print_msg("Profile successfully imported!") \ No newline at end of file diff --git a/konsave/vars.py b/konsave/vars.py new file mode 100644 index 0000000..5ba8621 --- /dev/null +++ b/konsave/vars.py @@ -0,0 +1,19 @@ +## IMPORT ## +import os + + +## GLOBAL VARS ## +HOME = os.path.expandvars('$HOME') +CONFIG_DIR = os.path.join(HOME, '.config') +KONSAVE_DIR = os.path.join(CONFIG_DIR, 'konsave') +PROFILES_DIR = os.path.join(KONSAVE_DIR, 'profiles') + +folder_names = ['gtk-2.0', 'gtk-3.0', 'gtk-4.0', 'Kvantum', 'latte'] +file_names = ['dolphinrc', 'konsolerc', 'kcminputrc', 'kdeglobals', 'kglobalshortcutsrc', 'klipperrc', 'krunnerrc', 'kscreenlockerrc', 'ksmserverrc', 'kwinrc', 'kwinrulesrc', 'plasma-org.kde.plasma.desktop-appletsrc', 'plasmarc', 'plasmashellrc', 'gtkrc', 'gtkrc-2.0', 'lattedockrc', 'breezerc', 'oxygenrc', 'lightlyrc', 'ksplashrc'] +export_extension = '.knsv' + +if not os.path.exists(PROFILES_DIR): + os.mkdirs(PROFILES_DIR) + +list_of_profiles = os.listdir(PROFILES_DIR) +length_of_lop = len(list_of_profiles) \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1fa68da --- /dev/null +++ b/setup.py @@ -0,0 +1,29 @@ +from setuptools import setup, find_packages + +def read_desc(): + with open('README.md', 'r') as desc: + return desc.read() + +setup ( + name="Konsave", + version="1.0.3", + author="Prayag Jain", + author_email="prayagjain2@gmail.com", + description = "A program that lets you save your Plasma configuration in an instant!", + long_description=read_desc(), + long_description_content_type="text/markdown", + url="https://www.github.com/prayag2/konsave/", + packages=find_packages(), + classifiers = [ + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: POSIX", + "Environment :: Console", + "Intended Audience :: End Users/Desktop", + 'Programming Language :: Python' + ], + entry_points={ + 'console_scripts': [ + "konsave = konsave.__main__:main" + ] + } +) \ No newline at end of file