├── tests ├── __init__.py └── test_pythonlibraryupdator.py ├── version.txt ├── docs ├── README.md └── LICENSE ├── scripts ├── __init__.py └── PythonLibraryUpdator.py ├── pyproject.toml └── poetry.lock /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 1.0.4 -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | Python Library Updator -------------------------------------------------------------------------------- /scripts/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = '1.0.4' -------------------------------------------------------------------------------- /tests/test_pythonlibraryupdator.py: -------------------------------------------------------------------------------- 1 | from scripts import __version__ 2 | 3 | 4 | def test_version(): 5 | assert __version__ == '1.0.4' 6 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [tool.poetry] 2 | name = "PythonLibraryUpdator" 3 | version = "1.0.4" 4 | description = "" 5 | authors = ["shervinbdndev "] 6 | 7 | [tool.poetry.dependencies] 8 | python = "^3.10" 9 | requests = "^2.28.1" 10 | colorama = "" 11 | 12 | [tool.poetry.dev-dependencies] 13 | pytest = "^5.2" 14 | 15 | [build-system] 16 | requires = ["poetry-core>=1.0.0"] 17 | build-backend = "poetry.core.masonry.api" 18 | -------------------------------------------------------------------------------- /docs/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Shervin Badanara 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /scripts/PythonLibraryUpdator.py: -------------------------------------------------------------------------------- 1 | if (__debug__): 2 | try: 3 | import os 4 | import sys 5 | import asyncio 6 | import requests 7 | import colorama 8 | import subprocess 9 | from typing_extensions import Self 10 | from typing import (Coroutine , Type , Union , Literal , Any , final) 11 | 12 | except ModuleNotFoundError.__doc__ as MNFE: 13 | raise MNFE from None 14 | 15 | finally: 16 | ... 17 | else: 18 | raise 19 | 20 | 21 | 22 | @final 23 | class PythonVersionUpdator: 24 | def __init__(self: Self) -> Union[Literal[None] , Self]: 25 | super(PythonVersionUpdator , self).__init__() 26 | try: 27 | os.system(command='cls') 28 | except: 29 | os.system(command='clear') 30 | print('\n%s Updating Interpreter . . .\n%s' % (colorama.ansi.Fore.GREEN , colorama.ansi.Fore.WHITE)) 31 | try: 32 | subprocess.call(args=['py' , '-m' , 'pip' , 'install' , '--upgrade' , 'pip']) 33 | except: 34 | subprocess.call(args=['python3' , '-m' , 'pip' , 'install' , '--upgrade' , 'pip']) 35 | finally: 36 | print('\n%s Interpreter Updated\n%s' % (colorama.ansi.Fore.GREEN , colorama.ansi.Fore.WHITE)) 37 | 38 | 39 | 40 | 41 | @final 42 | class PythonLibraryUpdator: 43 | 44 | @staticmethod 45 | async def update() -> Union[Coroutine , str]: 46 | print('\n%s Updating Libraries . . .\n%s' % (colorama.ansi.Fore.GREEN , colorama.ansi.Fore.WHITE)) 47 | for package in os.popen(cmd='pip freeze').readlines(): 48 | try: 49 | subprocess.call(args=['pip3' , 'install' , '--upgrade' , package.strip().split(sep='==')[0]]) 50 | except ConnectionError.__doc__ as CE: 51 | raise '%s %s Occurred' % (colorama.ansi.Fore.RED , CE) 52 | except requests.RequestException.__doc__ as RE: 53 | raise '%s %s Occurred' % (colorama.ansi.Fore.RED , RE) 54 | except KeyboardInterrupt.__doc__ as KI: 55 | raise '%s %s Occurred' % (colorama.ansi.Fore.RED , KI) 56 | else: 57 | print('\n%s All Libraries Updated Successfully \n%s' % (colorama.ansi.Fore.GREEN , colorama.ansi.Fore.WHITE)) 58 | 59 | def __new__(cls: Type[Self] , *args: Any , **kwargs: Any) -> Union[Literal[None] , Self]: 60 | if (sys.version_info[0:2] in [(3,7) , (3,8) , (3,9) , (3,10)]): 61 | return super().__new__(cls , *args , **kwargs) 62 | return None 63 | 64 | 65 | 66 | def main() -> Literal[None]: 67 | PythonVersionUpdator() 68 | asyncio.run(main=PythonLibraryUpdator().update()) 69 | 70 | 71 | 72 | if (__name__ == '__main__' and __package__ is None): 73 | main() -------------------------------------------------------------------------------- /poetry.lock: -------------------------------------------------------------------------------- 1 | [[package]] 2 | name = "atomicwrites" 3 | version = "1.4.1" 4 | description = "Atomic file writes." 5 | category = "dev" 6 | optional = false 7 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 8 | 9 | [[package]] 10 | name = "attrs" 11 | version = "22.1.0" 12 | description = "Classes Without Boilerplate" 13 | category = "dev" 14 | optional = false 15 | python-versions = ">=3.5" 16 | 17 | [package.extras] 18 | dev = ["cloudpickle", "coverage[toml] (>=5.0.2)", "furo", "hypothesis", "mypy (>=0.900,!=0.940)", "pre-commit", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "sphinx", "sphinx-notfound-page", "zope.interface"] 19 | docs = ["furo", "sphinx", "sphinx-notfound-page", "zope.interface"] 20 | tests = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins", "zope.interface"] 21 | tests_no_zope = ["cloudpickle", "coverage[toml] (>=5.0.2)", "hypothesis", "mypy (>=0.900,!=0.940)", "pympler", "pytest (>=4.3.0)", "pytest-mypy-plugins"] 22 | 23 | [[package]] 24 | name = "certifi" 25 | version = "2022.6.15" 26 | description = "Python package for providing Mozilla's CA Bundle." 27 | category = "main" 28 | optional = false 29 | python-versions = ">=3.6" 30 | 31 | [[package]] 32 | name = "charset-normalizer" 33 | version = "2.1.0" 34 | description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." 35 | category = "main" 36 | optional = false 37 | python-versions = ">=3.6.0" 38 | 39 | [package.extras] 40 | unicode_backport = ["unicodedata2"] 41 | 42 | [[package]] 43 | name = "colorama" 44 | version = "0.4.5" 45 | description = "Cross-platform colored terminal text." 46 | category = "main" 47 | optional = false 48 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 49 | 50 | [[package]] 51 | name = "idna" 52 | version = "3.3" 53 | description = "Internationalized Domain Names in Applications (IDNA)" 54 | category = "main" 55 | optional = false 56 | python-versions = ">=3.5" 57 | 58 | [[package]] 59 | name = "more-itertools" 60 | version = "8.14.0" 61 | description = "More routines for operating on iterables, beyond itertools" 62 | category = "dev" 63 | optional = false 64 | python-versions = ">=3.5" 65 | 66 | [[package]] 67 | name = "packaging" 68 | version = "21.3" 69 | description = "Core utilities for Python packages" 70 | category = "dev" 71 | optional = false 72 | python-versions = ">=3.6" 73 | 74 | [package.dependencies] 75 | pyparsing = ">=2.0.2,<3.0.5 || >3.0.5" 76 | 77 | [[package]] 78 | name = "pluggy" 79 | version = "0.13.1" 80 | description = "plugin and hook calling mechanisms for python" 81 | category = "dev" 82 | optional = false 83 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" 84 | 85 | [package.extras] 86 | dev = ["pre-commit", "tox"] 87 | 88 | [[package]] 89 | name = "py" 90 | version = "1.11.0" 91 | description = "library with cross-python path, ini-parsing, io, code, log facilities" 92 | category = "dev" 93 | optional = false 94 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" 95 | 96 | [[package]] 97 | name = "pyparsing" 98 | version = "3.0.9" 99 | description = "pyparsing module - Classes and methods to define and execute parsing grammars" 100 | category = "dev" 101 | optional = false 102 | python-versions = ">=3.6.8" 103 | 104 | [package.extras] 105 | diagrams = ["jinja2", "railroad-diagrams"] 106 | 107 | [[package]] 108 | name = "pytest" 109 | version = "5.4.3" 110 | description = "pytest: simple powerful testing with Python" 111 | category = "dev" 112 | optional = false 113 | python-versions = ">=3.5" 114 | 115 | [package.dependencies] 116 | atomicwrites = {version = ">=1.0", markers = "sys_platform == \"win32\""} 117 | attrs = ">=17.4.0" 118 | colorama = {version = "*", markers = "sys_platform == \"win32\""} 119 | more-itertools = ">=4.0.0" 120 | packaging = "*" 121 | pluggy = ">=0.12,<1.0" 122 | py = ">=1.5.0" 123 | wcwidth = "*" 124 | 125 | [package.extras] 126 | checkqa-mypy = ["mypy (==v0.761)"] 127 | testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "requests", "xmlschema"] 128 | 129 | [[package]] 130 | name = "requests" 131 | version = "2.28.1" 132 | description = "Python HTTP for Humans." 133 | category = "main" 134 | optional = false 135 | python-versions = ">=3.7, <4" 136 | 137 | [package.dependencies] 138 | certifi = ">=2017.4.17" 139 | charset-normalizer = ">=2,<3" 140 | idna = ">=2.5,<4" 141 | urllib3 = ">=1.21.1,<1.27" 142 | 143 | [package.extras] 144 | socks = ["PySocks (>=1.5.6,!=1.5.7)"] 145 | use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"] 146 | 147 | [[package]] 148 | name = "urllib3" 149 | version = "1.26.11" 150 | description = "HTTP library with thread-safe connection pooling, file post, and more." 151 | category = "main" 152 | optional = false 153 | python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4" 154 | 155 | [package.extras] 156 | brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] 157 | secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)"] 158 | socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] 159 | 160 | [[package]] 161 | name = "wcwidth" 162 | version = "0.2.5" 163 | description = "Measures the displayed width of unicode strings in a terminal" 164 | category = "dev" 165 | optional = false 166 | python-versions = "*" 167 | 168 | [metadata] 169 | lock-version = "1.1" 170 | python-versions = "^3.10" 171 | content-hash = "f475f5288872006c9f12cb1fe558622aef95cdc8328c2a00cfb4c0df52e147fd" 172 | 173 | [metadata.files] 174 | atomicwrites = [] 175 | attrs = [ 176 | {file = "attrs-22.1.0-py2.py3-none-any.whl", hash = "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"}, 177 | {file = "attrs-22.1.0.tar.gz", hash = "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6"}, 178 | ] 179 | certifi = [ 180 | {file = "certifi-2022.6.15-py3-none-any.whl", hash = "sha256:fe86415d55e84719d75f8b69414f6438ac3547d2078ab91b67e779ef69378412"}, 181 | {file = "certifi-2022.6.15.tar.gz", hash = "sha256:84c85a9078b11105f04f3036a9482ae10e4621616db313fe045dd24743a0820d"}, 182 | ] 183 | charset-normalizer = [ 184 | {file = "charset-normalizer-2.1.0.tar.gz", hash = "sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413"}, 185 | {file = "charset_normalizer-2.1.0-py3-none-any.whl", hash = "sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5"}, 186 | ] 187 | colorama = [ 188 | {file = "colorama-0.4.5-py2.py3-none-any.whl", hash = "sha256:854bf444933e37f5824ae7bfc1e98d5bce2ebe4160d46b5edf346a89358e99da"}, 189 | {file = "colorama-0.4.5.tar.gz", hash = "sha256:e6c6b4334fc50988a639d9b98aa429a0b57da6e17b9a44f0451f930b6967b7a4"}, 190 | ] 191 | idna = [ 192 | {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, 193 | {file = "idna-3.3.tar.gz", hash = "sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"}, 194 | ] 195 | more-itertools = [ 196 | {file = "more-itertools-8.14.0.tar.gz", hash = "sha256:c09443cd3d5438b8dafccd867a6bc1cb0894389e90cb53d227456b0b0bccb750"}, 197 | {file = "more_itertools-8.14.0-py3-none-any.whl", hash = "sha256:1bc4f91ee5b1b31ac7ceacc17c09befe6a40a503907baf9c839c229b5095cfd2"}, 198 | ] 199 | packaging = [ 200 | {file = "packaging-21.3-py3-none-any.whl", hash = "sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"}, 201 | {file = "packaging-21.3.tar.gz", hash = "sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb"}, 202 | ] 203 | pluggy = [ 204 | {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, 205 | {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, 206 | ] 207 | py = [ 208 | {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, 209 | {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, 210 | ] 211 | pyparsing = [ 212 | {file = "pyparsing-3.0.9-py3-none-any.whl", hash = "sha256:5026bae9a10eeaefb61dab2f09052b9f4307d44aee4eda64b309723d8d206bbc"}, 213 | {file = "pyparsing-3.0.9.tar.gz", hash = "sha256:2b020ecf7d21b687f219b71ecad3631f644a47f01403fa1d1036b0c6416d70fb"}, 214 | ] 215 | pytest = [ 216 | {file = "pytest-5.4.3-py3-none-any.whl", hash = "sha256:5c0db86b698e8f170ba4582a492248919255fcd4c79b1ee64ace34301fb589a1"}, 217 | {file = "pytest-5.4.3.tar.gz", hash = "sha256:7979331bfcba207414f5e1263b5a0f8f521d0f457318836a7355531ed1a4c7d8"}, 218 | ] 219 | requests = [ 220 | {file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"}, 221 | {file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"}, 222 | ] 223 | urllib3 = [ 224 | {file = "urllib3-1.26.11-py2.py3-none-any.whl", hash = "sha256:c33ccba33c819596124764c23a97d25f32b28433ba0dedeb77d873a38722c9bc"}, 225 | {file = "urllib3-1.26.11.tar.gz", hash = "sha256:ea6e8fb210b19d950fab93b60c9009226c63a28808bc8386e05301e25883ac0a"}, 226 | ] 227 | wcwidth = [ 228 | {file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"}, 229 | {file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"}, 230 | ] 231 | --------------------------------------------------------------------------------