{ "info": { "author": "Carson", "author_email": "jackparadise520a@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Apache Software License", "Natural Language :: Chinese (Traditional)", "Natural Language :: English", "Operating System :: Microsoft", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: System :: Logging" ], "description": "===================\nFile\n===================\n\n.. sectnum::\n\n\n\nInstall\n===============\n\n * ``pip install carson-file``\n\nimport packages\n===============\n\n.. code-block:: python\n\n from Carson.Class.File import FileHelper, TempFile, MemoryFile\n\n\nSOURCE DOCUMENT\n===============\n\nFileHelper\n--------------\n\nclass FileHelper\n Class methods defined here:\n \n delete_dir(dir_path)\n recursive delete all files include directory.\n \n file_path_add_prefix(file, pre_fix_name) -> str\n >>> FileHelper.file_path_add_prefix(\"C:\\Test\\fileA.txt\", \"My\")\n 'C:\\Test\\MyfileA.txt'\n \n get_file_attrib(file)\n \n get_file_info(file)\n \n get_file_path(file)\n to get filename which name is too long\n \n get_file_properties(file) -> dict\n Read all properties of the given file and return them as a dictionary.\n \n EXAMPLE::\n \n prop = FileHelper.get_file_properties(r\"C:\\Windows\\System32\\cmd.exe\")\n for key, value in prop['StringFileInfo'].items():\n print(f'{key:<15} {value if value else \"\":<30}')\n\n OUTPUT::\n\n Comments\n InternalName cmd\n ProductName Microsoft\u00ae Windows\u00ae Operating System\n CompanyName Microsoft Corporation\n LegalCopyright \u00a9 Microsoft Corporation. All rights reserved.\n ProductVersion 10.0.18362.356\n FileDescription Windows \u547d\u4ee4\u8655\u7406\u7a0b\u5f0f\n LegalTrademarks\n PrivateBuild\n FileVersion 10.0.18362.356 (WinBuild.160101.0800)\n OriginalFilename Cmd.Exe.MUI\n SpecialBuild\n \n if_dir_not_exist_then_create(chk_path, is_dir_name_have_dot=False) -> bool\n :return: True: create successful, otherwise not.\n \n is_illegal_file_name(file_path)\n \n move_file(src_file, dst_file)\n .. warning:: dst_file that will be replaced of src_file no matter dst_file exists or not.\n\n \n name_normalized(file_path, is_need_rename=False, list_replace_mapping=(('[', '\u2636'), (']', '\u2632')), option: dict) -> tuple\n if filename that contains illegal character then will replace those character by \"list_replace_mapping\" to rename the file.\n \n USAGE::\n\n name_normalized = FileHelper.name_normalized\n new_path, be_normalized = name_normalized(\"C:\\\\[dir]\\\\sub_dir\\\\my_[test].txt\")\n ('C:\\\\\u2636dir\u2632\\\\sub_dir\\\\my_\u2636test\u2632.txt', True)\n\n name_normalized(\"C:\\\\[dir]\\\\sub_dir\\\\my_[test].txt\", only_base_name=True)\n ('C:\\\\[dir]\\\\sub_dir\\\\my_\u2636test\u2632.txt', Ture)\n \n name_normalized(\"my_[test].txt\", only_base_name=True)\n my_\u2636test\u2632.txt, True\n \n name_normalized(\"my_[test].txt\")\n 'my_\u2636test\u2632.txt', True\n \n name_normalized(\"my_test.txt\")\n 'my_test.txt', False\n \n rename(src_file, dst_file, ignore_file_exist_error)\n\n copy_config(org_config) -> configparser.ConfigParser\n .. note:: you can assign the string to `org_config`, but its data must be able to read by ConfigParser\n\n USAGE::\n\n org_config = configparser.ConfigParser()\n org_config.read([file1, file2], encoding='utf-8')\n new_config = FileHelper.copy_config(org_config)\n\n Static methods defined here:\n \n kill_process(kill_name_list: List[str])\n \n\nclass MemoryFile\n easier to write or read data from memory\n \n USAGE::\n \n import pandas as pd\n tmp_file = MemoryFile()\n tmp_file.write('name|age')\n tmp_file.write('Carson|26')\n tmp_file.writelines(['Person_1|18', 'Person_2|12'])\n print(tmp_file.read())\n tmp_file.io.seek(0)\n print(tmp_file.readline()) # make sure cursor waiting position is what you want before readline\n tmp_file.io.seek(0)\n df = pd.read_csv(tmp_file.io, sep='|') # must seek(0) before read_csv.\n tmp_file.close()\n \n with MemoryFile(MemoryFile.IoType.BYTE) as tmp_file_2:\n tmp_file_2.write('name|age')\n tmp_file_2.write('\u4e2d\u6587|26')\n tmp_file_2.writelines(['Person_1|18', 'Person_2|12'])\n print(tmp_file_2.read())\n tmp_file_2.seek(0)\n print(tmp_file_2.readline())\n tmp_file_2.seek(0)\n df = pd.read_csv(tmp_file_2.io, sep='|')\n \n with open('temp.temp', 'wb') as f:\n f.write(tmp_file_2.read())\n with open('temp.temp', 'r', encoding='utf-8') as f:\n print(f.read())\n\nclass TempFile\n If you need temp file and that can be auto-deleted after you aren't using it.\n \n USAGE::\n\n with TempFile('temp.temp') as tmp_f:\n tmp_f.close() # it's only using for other programs will do something by it (Option)\n other_process(tmp_file_path)\n\n\nmore detail please see the source file.\n\nall function and class have illustrate in source file", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/CarsonSlovoka/carson-file/tarball/v0.0.1", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/CarsonSlovoka/carson-file", "keywords": "File", "license": "Apache-2.0", "maintainer": "", "maintainer_email": "", "name": "carson-file", "package_url": "https://pypi.org/project/carson-file/", "platform": "", "project_url": "https://pypi.org/project/carson-file/", "project_urls": { "Download": "https://github.com/CarsonSlovoka/carson-file/tarball/v0.0.1", "Homepage": "https://github.com/CarsonSlovoka/carson-file" }, "release_url": "https://pypi.org/project/carson-file/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "create a temp file, memory file, rename, move, copy, kill the process, get attribute, create a directory, etc.", "version": "0.0.1" }, "last_serial": 5893891, "releases": { "0.0.0": [ { "comment_text": "", "digests": { "md5": "0fc34a4c8c8d94756493fcbc8717a6f3", "sha256": "9428f42124cceaf36875eee5b4fbe732b49f81314f6622c8b3a94e6937b547cb" }, "downloads": -1, "filename": "carson-file-0.0.0.tar.gz", "has_sig": false, "md5_digest": "0fc34a4c8c8d94756493fcbc8717a6f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10083, "upload_time": "2019-09-26T10:40:15", "url": "https://files.pythonhosted.org/packages/34/13/b18429727e77282cb9e29e286c82854c155a6cc7298fcfa1e9fa9ecdc6dd/carson-file-0.0.0.tar.gz" } ], "0.0.1": [ { "comment_text": "", "digests": { "md5": "5bc4e10b85b136f30cd157d1a64499bb", "sha256": "9ffec1554953ce05559ff155f22cbfdce232d12c91708cd0e6e6ecb58b1c5f73" }, "downloads": -1, "filename": "carson-file-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5bc4e10b85b136f30cd157d1a64499bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10046, "upload_time": "2019-09-27T03:28:52", "url": "https://files.pythonhosted.org/packages/29/2c/80a17da6412e3acc47af51c5d3ded79a211149607da4dfcdf18bd2e8531a/carson-file-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "5bc4e10b85b136f30cd157d1a64499bb", "sha256": "9ffec1554953ce05559ff155f22cbfdce232d12c91708cd0e6e6ecb58b1c5f73" }, "downloads": -1, "filename": "carson-file-0.0.1.tar.gz", "has_sig": false, "md5_digest": "5bc4e10b85b136f30cd157d1a64499bb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10046, "upload_time": "2019-09-27T03:28:52", "url": "https://files.pythonhosted.org/packages/29/2c/80a17da6412e3acc47af51c5d3ded79a211149607da4dfcdf18bd2e8531a/carson-file-0.0.1.tar.gz" } ] }