{ "info": { "author": "Adam Wasilewski", "author_email": "adam@wasilewski.pw", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Few handy python modules\n\nHey, I wanna share with You my python modules,\n\nI have for now:\n* logger\n* tictoc\n* hashing passwords\n* files_info\n* downloading files\n* password validation\n\nI hope You enjoy it!\n\nPS. You can find source codes on [my github](https://github.com/admw15/modules)\n\n## Docs:\n* logger: \n##### Info\n\nPackage contains \"CreateLogger\" class that quickly create logger for us, \ninstead of importing logging module and adding handlers etc...\n\nlog file has default name same as file name, with .log.\nAlso it is in new folder called 'logs' \nExample: python_file.py -> logs/python_file.log\n\n##### Arguments:\n* logger_name \nType: str \nDefault: your file name \nDescription: logger name should be unique! \nDefault is your filename (without .py) so it will look like: \nmailer/flask_receiver/my_first_file etc.\n\nWARNING: If you have file (parent) \nwith logger, and you are importing in it another local file (child), \nthen remember to give a new logger name to child! \n\n```python\n# parent.py:\nimport handymodules\nimport child # local file\n\nlog = handymodules.CreateLogger() # its ok, don't need any arguments\nlog.info('Starting...')\nchild.function()\nlog.info('Done')\n```\n\n```python\n# child.py:\nimport handymodules\nlog = handymodules.CreateLogger() # BAD!!!\nlog = handymodules.CreateLogger('child') # Good\n\ndef function():\n # do something\n log.warning('Something is wrong')\n```\n\nIn this case, there are two loggers and two files, if you want to have \nthese two loggers in one file, then you should edit line in child \n```python\nlog = handymodules.CreateLogger('child', log_filename='parent')\n``` \nRemember to use file basename (without .py) \n\n* stream_handler \nType: bool \nDefault: True \nDescription: add a stream handler to your logger (logs in console)\n\n* file_handler \nType: bool \nDefault: True \nDescription: add a file handler to your logger. It creates \"logs\" \nfolder inside directory where your file is. \n\n* log_filename \nType: str \nDefault: filename \nDescription: Just what it says, default logfile has same name as your \npython file, but with .log \nEg. flask_app.py -> logs/flask_app.log \n\n##### Kwargs\n* timed_rotating_file \nType: bool \nDefault: False \nDescription: if file handler should be timed rotating. If True, it\nwill change every midnight \n\n* days_to_keep \nType: int \nDefault: 7 \nDescription: only if timed rotated file, select how long should logger\nkeep old daily files\n\n* log_inside_folder \nType: bool \nDefault: False \nDescription: if True, logs are saving inside logs and inside one \nmore folder, eg. \nFalse - logs/flask_app.log \nTrue - logs/flask_app/flask_app.log \n\nUseful when using timed rotating for like month or three months\n\n##### Usage:\n\n```python\nimport handymodules\nlog = handymodules.CreateLogger(stream_handler=True, file_handler=False)\n\nlog.info('some info')\nlog.debug('some info')\nlog.warning('some info')\nlog.error('some info')\nlog.critical('some info')\n\ntry:\n x += 2\nexcept:\n log.add_file_handler()\n log.exception('Only when exception!')\n\nlog.change_level('warning')\nlog.change_format('%(message)s')\n```\n\nSample log file line:\n\n`2019-03-27 20:52:27,471 - flask_app - INFO - some info`\n\n* tictoc:\n\n```python\nimport tictoc as t\n\nt.tic()\nt.toc()\n# more code\nt.toc()\n\nt.tic()\nt.toc()\n```\nYou can use toc multiple times, it will count since last `tic()` function\n\ntoc() output:\n`Elapsed time: 2.562 seconds.`\n\nAlso there is a class with this functionality, \nYou can have now multiple timers.\n```python\nimport handymodules\nt = handymodules.TicToc()\nt.tic()\nt.toc()\n```\n\n* hashing passwords\n\nTwo functions:\n```python\nimport handymodules as h\nhashed = h.hash_password('Pa$$w0rd')\n# store it somewhere!\nh.validate_hashed_password('Pa$$w0rd', hashed)\n```\nIt's simple and secure, returns `True` or `False`\nI am using SHA3-512.\n\n* files_info\n```python\nimport handymodules\nfilename = handymodules.get_filename()\nfilepath = handymodules.get_file_abspath(file)\n```\n\nit will always return filename that uses it, \nand absolute file path to the specific file\n\n* password validation\n\n```python\nimport handymodules.password_validation as p\npassword = p.validate_password()\n```\nin `password` variable You have user password from keyboard. \nIt was taken by getpass so it wasn't visible for others (just like in linux) \n\nI recommend to use it with hashing_password, \ndo not store passwords in plain text!\n\n* download_file\n\n```python\nimport handymodules.downloading_file as d\n\nurl1 = 'http://example.com/text.txt'\nurl2 = 'http://example.com/zipfile.zip'\n\nd.download(url1)\nd.download_zip(url2)\n```\n\nYou can simply download any file from web giving url only. \nZip default will be unpacked to folder (with same name as package) and deleted, \nof course You can change it\n\n\n\n### changelog:\n* 2.1.0 - Added support to Python versions lower than 3.6 (removed f-strings)\n* 2.0.1 - updated docs\n* 2.0.0 - Changed name to handymodules, added kwargs to CreateLogger, \nyou can now change logfile name, updated docs", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://pypi.org/project/handymodules/", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "handymodules", "package_url": "https://pypi.org/project/handymodules/", "platform": "", "project_url": "https://pypi.org/project/handymodules/", "project_urls": { "Homepage": "https://pypi.org/project/handymodules/" }, "release_url": "https://pypi.org/project/handymodules/2.1.0/", "requires_dist": null, "requires_python": "", "summary": "A few handy, useful python modules", "version": "2.1.0" }, "last_serial": 5959306, "releases": { "2.0.0": [ { "comment_text": "", "digests": { "md5": "ba534cb3161ae229f3f3c6081cb11e3d", "sha256": "d5c0c2f39c46b1eb8fd8ef7bcaa5cb00aed8b52c0c8edfc745bef90722ebb62f" }, "downloads": -1, "filename": "handymodules-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ba534cb3161ae229f3f3c6081cb11e3d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9303, "upload_time": "2019-09-17T14:05:23", "url": "https://files.pythonhosted.org/packages/5e/d9/017f6f9ba88db2e61f37ff2f082c0842e15492d7ba869a6a687e7c0aa239/handymodules-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "03aaaaa31c5b1faf35a125648f053da7", "sha256": "41b4dad87775058072932b1eeb2ea6fa073df04c77cc40d11bc75dc67763ebdc" }, "downloads": -1, "filename": "handymodules-2.0.0.tar.gz", "has_sig": false, "md5_digest": "03aaaaa31c5b1faf35a125648f053da7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7352, "upload_time": "2019-09-17T14:05:25", "url": "https://files.pythonhosted.org/packages/a8/6a/353a47969c28ed9409dc2c0e799d190e247493eedb6dc1be5cdcc8d2b797/handymodules-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "f2619b3be54aa09dfe723a5c78855237", "sha256": "bf37d9ecf995ac7f856c89fc4b8351ca830b0c4ebba5de01725383dedf100b60" }, "downloads": -1, "filename": "handymodules-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "f2619b3be54aa09dfe723a5c78855237", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9310, "upload_time": "2019-09-17T14:08:06", "url": "https://files.pythonhosted.org/packages/1b/38/1e57177ee459d14a858f78bfb8a6197a498fb133a001d6fe726a95579861/handymodules-2.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e0a8c5f1200b896e60b2b3038455a04f", "sha256": "927d2bf44aea6ee9d12db108a160a2763c77bc45a6ae53fdc5b2b8d9d48a5587" }, "downloads": -1, "filename": "handymodules-2.0.1.tar.gz", "has_sig": false, "md5_digest": "e0a8c5f1200b896e60b2b3038455a04f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7372, "upload_time": "2019-09-17T14:08:08", "url": "https://files.pythonhosted.org/packages/42/a6/0057d4356f9442f747d76af1afcfe5c701d33023a82869b4d521065a27cd/handymodules-2.0.1.tar.gz" } ], "2.1.0": [ { "comment_text": "", "digests": { "md5": "e4b4225264d0de82f4878a9b5d7df73a", "sha256": "b5a503fcf7bc386299a04106c146031638c1edf6c53bac36095b37b03f48c2d2" }, "downloads": -1, "filename": "handymodules-2.1.0.tar.gz", "has_sig": false, "md5_digest": "e4b4225264d0de82f4878a9b5d7df73a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7461, "upload_time": "2019-10-11T09:18:30", "url": "https://files.pythonhosted.org/packages/28/79/2a7f85abbf6c31dc238f45f55b21f051b2cbce9b7845af9d8d178dc195b0/handymodules-2.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e4b4225264d0de82f4878a9b5d7df73a", "sha256": "b5a503fcf7bc386299a04106c146031638c1edf6c53bac36095b37b03f48c2d2" }, "downloads": -1, "filename": "handymodules-2.1.0.tar.gz", "has_sig": false, "md5_digest": "e4b4225264d0de82f4878a9b5d7df73a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7461, "upload_time": "2019-10-11T09:18:30", "url": "https://files.pythonhosted.org/packages/28/79/2a7f85abbf6c31dc238f45f55b21f051b2cbce9b7845af9d8d178dc195b0/handymodules-2.1.0.tar.gz" } ] }