{"id":22927875,"url":"https://github.com/ddc/ddcutils","last_synced_at":"2025-04-01T15:44:52.470Z","repository":{"id":216704224,"uuid":"741217785","full_name":"ddc/ddcUtils","owner":"ddc","description":"Few Utility Functions","archived":false,"fork":false,"pushed_at":"2024-04-22T19:45:21.000Z","size":218,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-23T20:28:55.370Z","etag":null,"topics":["python3","utilities","utilities-library","utility","utility-library","utils","utils-library"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ddc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-09T23:56:51.000Z","updated_at":"2024-05-31T21:07:04.251Z","dependencies_parsed_at":"2024-03-20T21:43:17.748Z","dependency_job_id":"fa8bcfcd-00e1-46aa-b597-daf08abeaed0","html_url":"https://github.com/ddc/ddcUtils","commit_stats":null,"previous_names":["ddc/ddcutils"],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddc%2FddcUtils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddc%2FddcUtils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddc%2FddcUtils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ddc%2FddcUtils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ddc","download_url":"https://codeload.github.com/ddc/ddcUtils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246667386,"owners_count":20814729,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["python3","utilities","utilities-library","utility","utility-library","utils","utils-library"],"created_at":"2024-12-14T09:16:38.317Z","updated_at":"2025-04-01T15:44:52.451Z","avatar_url":"https://github.com/ddc.png","language":"Python","funding_links":["https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ","https://github.com/sponsors/ddc","https://ko-fi.com/ddcsta"],"categories":[],"sub_categories":[],"readme":"# File Utilities\nFew File Utilities and some OS Functions\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-brightgreen.svg?style=plastic)](https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ)\n[![License](https://img.shields.io/github/license/ddc/ddcUtils.svg)](https://github.com/ddc/ddcUtils/blob/master/LICENSE)\n[![PyPi](https://img.shields.io/pypi/v/ddcUtils.svg)](https://pypi.python.org/pypi/ddcUtils)\n[![PyPI Downloads](https://static.pepy.tech/badge/ddcUtils)](https://pepy.tech/projects/ddcUtils)\n[![codecov](https://codecov.io/gh/ddc/ddcUtils/graph/badge.svg?token=1ULU74GF57)](https://codecov.io/gh/ddc/ddcUtils)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A//actions-badge.atrox.dev/ddc/ddcUtils/badge?ref=main\u0026label=build\u0026logo=none)](https://actions-badge.atrox.dev/ddc/ddcUtils/goto?ref=main)\n[![Python](https://img.shields.io/pypi/pyversions/ddcUtils.svg)](https://www.python.org)\n\n\n# Install\n```shell\npip install ddcUtils\n```\n\n\n# Conf File Utils\n\nFile example - file.ini:\n\n    [main]\n    files=5\n    path=\"/tmp/test_dir\"\n    port=5432\n    list=1,2,3,4,5,6\n\n\n+ GET_ALL_VALUES\n  + Get all values from an .ini config file structure and returns them as a dictionary\n  + mixed_values will return all values as an object instead of dict\n```python\nfrom ddcUtils import ConfFileUtils\ncfu = ConfFileUtils()\ncfu.get_all_values(file_path, mixed_values=False)\n```\n\n\n\n+ GET_SECTION_VALUES\n  + Get all section values from an .ini config file structure and returns them as a dictionary\n```python\nfrom ddcUtils import ConfFileUtils\ncfu = ConfFileUtils()\ncfu.get_section_values(file_path, section)\n```\n\n\n\n+ GET_VALUE\n  + Get value from an .ini config file structure and returns it\n```python\nfrom ddcUtils import ConfFileUtils\ncfu = ConfFileUtils()\ncfu.get_value(file_path, section, config_name)\n```\n\n\n\n+ SET_VALUE\n  + Set value from an .ini config file structure and returns True or False\n```python\nfrom ddcUtils import ConfFileUtils\ncfu = ConfFileUtils()\ncfu.set_value(file_path, section_name, config_name, new_value, commas=False)\n```\n\n\n# File Utils\n\n+ OPEN\n  + Open the given file or directory in explorer or notepad and returns True for success or False for failed access\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.open(path)\n```\n\n\n\n+ LIST_FILES\n  + List all files in the given directory and returns them in a tuple sorted by creation time in ascending order\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.list_files(directory, starts_with, ends_with)\n```\n\n\n\n+ GZIP\n  + Compress the given file and returns the Path for success or None if failed\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.gzip(input_file_path, output_dir=None)\n```\n\n\n\n+ UNZIP\n  + Unzips the given file.zip and returns ZipFile for success or None if failed\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.unzip(file_path, out_pathNone)\n```\n\n\n\n+ REMOVE\n  + Remove the given file or dir and returns True if it was successfully removed\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.remove(path)\n```\n\n\n\n+ RENAME\n  + Rename the given file and returns True if the file was successfully\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.rename(from_name, to_name)\n```\n\n\n\n+ COPY_DIR\n  + Copy files from src to dst and returns True or False\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.copy_dir(src, dst, symlinks=False, ignore=None)\n```\n\n\n\n+ DOWNLOAD_FILE\n  + Download file from remote url to local and returns True or False\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.download_file(remote_file_url, local_file_path)\n```\n\n\n\n+ GET_EXE_BINARY_TYPE\n  + Returns the binary type of the given windows EXE file\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.get_exe_binary_type(file_path)\n```\n\n\n\n+ IS_OLDER_THAN_X_DAYS\n  + Check if a file or directory is older than the specified number of days\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\nfu.is_older_than_x_days(path, days)\n```\n\n\n\n+ COPY\n  + Copy a file to another location\n```python\nfrom ddcUtils import FileUtils\nfu = FileUtils()\ncopy(src_path, dst_path)\n```\n\n\n\n# Object\n+ This class is used for creating a simple class object\n ```python\nfrom ddcUtils import Object\nobj = Object()\nobj.test = \"test\"\n```   \n\n\n# Misc Utils\n\n+ CLEAR_SCREEN\n  + Clears the terminal screen\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.clear_screen()\n```\n\n\n\n+ USER_CHOICE\n  + This function will ask the user to select an option\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.user_choice()\n```\n\n\n\n+ GET_ACTIVE_BRANCH_NAME\n  + Returns the name of the active branch if found, else returns None\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.get_active_branch_name(git_dir=\".git\")\n```\n\n\n\n+ GET_CURRENT_DATE_TIME\n  + Returns the current date and time on UTC timezone\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.get_current_date_time()\n```\n\n\n\n+ CONVERT_DATETIME_TO_STR_LONG\n  + Converts a datetime object to a long string\n  + returns: \"Mon Jan 01 2024 21:43:04\"\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.convert_datetime_to_str_long(date)\n```\n\n\n\n+ CONVERT_DATETIME_TO_STR_SHORT\n  + Converts a datetime object to a short string\n  + returns: \"2024-01-01 00:00:00.000000\"\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.convert_datetime_to_str_short(date)\n```\n\n\n\n+ CONVERT_STR_TO_DATETIME_SHORT\n  + Converts a str to a datetime\n  + input: \"2024-01-01 00:00:00.000000\"\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.convert_str_to_datetime_short(datetime_str)\n```\n\n\n\n+ GET_CURRENT_DATE_TIME_STR_LONG\n  + Returns the current date and time as string\n  + returns: \"Mon Jan 01 2024 21:47:00\"\n```python\nfrom ddcUtils import MiscUtils\nmu = MiscUtils()\nmu.get_current_date_time_str_long()\n```\n\n\n# OS Utils\n\n+ GET_OS_NAME\n  + Get OS name\n```python\nfrom ddcUtils import OsUtils\nou = OsUtils()\nget_os_name()\n```\n\n\n\n+ IS_WINDOWS\n  + Check if OS is Windows\n```python\nfrom ddcUtils import OsUtils\nou = OsUtils()\nis_windows()\n```\n\n\n\n+ GET_CURRENT_PATH\n  + Returns the current working directory\n```python\nfrom ddcUtils import OsUtils\nou = OsUtils()\nget_current_path()\n```\n\n\n\n+ GET_PICTURES_PATH\n  + Returns the pictures directory inside the user's home directory\n```python\nfrom ddcUtils import OsUtils\nou = OsUtils()\nget_pictures_path()\n```\n\n\n\n+ GET_DOWNLOADS_PATH\n  + Returns the download directory inside the user's home directory\n```python\nfrom ddcUtils import OsUtils\nou = OsUtils()\nget_downloads_path()\n```\n\n\n# Source Code\n### Build\n```shell\npoetry build -f wheel\n```\n\n\n\n# Run Tests and Get Coverage Report using Poe\n```shell\npoetry update --with test\npoe tests\n```\n\n\n\n# License\nReleased under the [MIT License](LICENSE)\n\n\n\n# Buy me a cup of coffee\n+ [GitHub Sponsor](https://github.com/sponsors/ddc)\n+ [ko-fi](https://ko-fi.com/ddcsta)\n+ [Paypal](https://www.paypal.com/ncp/payment/6G9Z78QHUD4RJ)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddc%2Fddcutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fddc%2Fddcutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fddc%2Fddcutils/lists"}