From 287e2f1120c840f90181964a6e35bf0cb7621ae3 Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 18:52:54 +0330 Subject: [PATCH 01/10] CLI tests added --- .github/workflows/test.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 42ab46e..6d1d677 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,6 +27,22 @@ jobs: run: | python -m pip install --upgrade pip pip install . + - name: CLI Tests - Version Check + run: | + python -m dmeta --version + dmeta -v + - name: CLI Tests - Clear single .docx file + run: | + dmeta --clear "tests/test_a.docx" + - name: CLI Tests - Clear all .docx files + run: | + dmeta --clear-all + - name: CLI Tests - Update single .docx file + run: | + dmeta --update "tests/test_a.docx" --config "tests/config.json" + - name: CLI Tests - Update all .docx files + run: | + dmeta --update-all --config "tests/config.json" - name: Test requirements Installation run: | python otherfiles/requirements-splitter.py From b800a46d5e47cc70e58342f0849fb44dbb8078cf Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 18:55:11 +0330 Subject: [PATCH 02/10] refactorings applied --- dmeta/__main__.py | 20 +++++++------------- dmeta/functions.py | 7 ++++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/dmeta/__main__.py b/dmeta/__main__.py index 90d2956..f65becb 100644 --- a/dmeta/__main__.py +++ b/dmeta/__main__.py @@ -1,7 +1,6 @@ """DMeta main.""" import argparse -from art import tprint -from dmeta.functions import run_dmeta, dmeta_help +from dmeta.functions import run_dmeta from dmeta.params import DMETA_VERSION @@ -11,9 +10,6 @@ def main(): :return: None """ - tprint("DMeta") - tprint("V:" + DMETA_VERSION) - dmeta_help() parser = argparse.ArgumentParser() parser.add_argument( '--clear', @@ -48,16 +44,14 @@ def main(): type=str, help="the `config` command specifices the way metadata in the .docx files get updated." ) - # parse the arguments from the standard input - args = parser.parse_args() + parser.add_argument('--version', help="version", action='store_true', default=False) + parser.add_argument('-v', help="version", action='store_true', default=False) + args = parser.parse_known_args()[0] + if args.version or args.v: + print(DMETA_VERSION) + return run_dmeta(args) if __name__ == "__main__": main() - -# testcases: -# dmeta --clear "test.docx" -# dmeta --clear-all -# dmeta --update "test.docx" --config "cnf.json" -# dmeta --update-all --config "cnf.json" diff --git a/dmeta/functions.py b/dmeta/functions.py index e957c25..cc34f6d 100644 --- a/dmeta/functions.py +++ b/dmeta/functions.py @@ -3,9 +3,10 @@ import os import shutil import zipfile +from art import tprint from .util import remove_format, extract_docx, read_json import defusedxml.ElementTree as ET -from .params import CORE_XML_MAP, APP_XML_MAP, OVERVIEW +from .params import CORE_XML_MAP, APP_XML_MAP, OVERVIEW, DMETA_VERSION def clear(docx_file_name): @@ -169,3 +170,7 @@ def run_dmeta(args): print("when using the `update-all` command, you should set the .json config file through the --config command") else: update_all(args.config[0]) + else: + tprint("DMeta") + tprint("V:" + DMETA_VERSION) + dmeta_help() From 2a34ca886f13ddd92926a907a9e76c88cad4c05b Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 18:56:19 +0330 Subject: [PATCH 03/10] CHANGELOG.md updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b81801c..5ae58b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed ## [0.1] - 2024-05-29 ### Added +- `CLI` Handler - `main` function in `__main__.py` - `README.md` - `clear` function `functions.py` From 5f6b934b5c9dfd8a6a1fbd347a0e3f41a6c098d5 Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 19:00:12 +0330 Subject: [PATCH 04/10] add dir to check the generated files --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d1d677..fac1348 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,15 +34,19 @@ jobs: - name: CLI Tests - Clear single .docx file run: | dmeta --clear "tests/test_a.docx" + dir ./tests - name: CLI Tests - Clear all .docx files run: | dmeta --clear-all + dir ./tests - name: CLI Tests - Update single .docx file run: | dmeta --update "tests/test_a.docx" --config "tests/config.json" + dir ./tests - name: CLI Tests - Update all .docx files run: | dmeta --update-all --config "tests/config.json" + dir ./tests - name: Test requirements Installation run: | python otherfiles/requirements-splitter.py From c736a81269e3d4fb9d8f8742b450291c37399049 Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 19:02:30 +0330 Subject: [PATCH 05/10] add traversing to .tests directory --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fac1348..59c99d0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,16 +37,20 @@ jobs: dir ./tests - name: CLI Tests - Clear all .docx files run: | - dmeta --clear-all - dir ./tests + cd ./tests + dmeta --clear-all + dir . + cd - - name: CLI Tests - Update single .docx file run: | dmeta --update "tests/test_a.docx" --config "tests/config.json" dir ./tests - name: CLI Tests - Update all .docx files run: | + cd ./tests dmeta --update-all --config "tests/config.json" - dir ./tests + dir . + cd - - name: Test requirements Installation run: | python otherfiles/requirements-splitter.py From eeff46fa54b8a81498b06895cdd2f8c836711522 Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 19:05:53 +0330 Subject: [PATCH 06/10] replace dir with ls --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59c99d0..65c823a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,22 +34,22 @@ jobs: - name: CLI Tests - Clear single .docx file run: | dmeta --clear "tests/test_a.docx" - dir ./tests + ls ./tests - name: CLI Tests - Clear all .docx files run: | cd ./tests dmeta --clear-all - dir . + ls . cd - - name: CLI Tests - Update single .docx file run: | dmeta --update "tests/test_a.docx" --config "tests/config.json" - dir ./tests + ls ./tests - name: CLI Tests - Update all .docx files run: | cd ./tests - dmeta --update-all --config "tests/config.json" - dir . + dmeta --update-all --config "./config.json" + ls . cd - - name: Test requirements Installation run: | From b521a9304c66039d75ce3fb954a2efeef209061d Mon Sep 17 00:00:00 2001 From: AHReccese Date: Thu, 13 Jun 2024 19:21:04 +0330 Subject: [PATCH 07/10] README.md updated --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 63f60f0..9fa3ac6 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ ## Overview

-DMeta is an open source Python package that provides ... TODO +DMeta is an open source Python package that removes metadata of microsoft office files.

@@ -84,30 +84,68 @@ DMeta is an open source Python package that provides ... TODO - Run `pip install .` ## Usage +### Programmatically +#### Clear metadata for a .docx file +```python +import os +from dmeta.functions import clear + +DOCX_FILE_PATH = os.path.join(os.getcwd(), "SAMPLE.docx") +clear(DOCX_FILE_PATH) +``` +#### Clear metadata for all existing .docx files in the current directory +```python +from dmeta.functions import clear_all +clear_all() +``` +#### Update metadata for a .docx file +```python +import os +from dmeta.functions import update + +CONFIG_FILE_PATH = os.path.join(os.getcwd(), "CONFIG.json") +DOCX_FILE_PATH = os.path.join(os.getcwd(), "SAMPLE.docx") +update(DOCX_FILE_PATH, DOCX_FILE_PATH) +``` + +### Update metadata for all existing .docx files in the current directory +```python +import os +from dmeta.functions import update_all + +CONFIG_FILE_PATH = os.path.join(os.getcwd(), "CONFIG.json") +update_all(CONFIG_FILE_PATH) +``` + +### CLI +⚠️ You can use `dmeta` or `python -m dmeta` to run this program +#### Version +```console +dmeta -v +dmeta --version +``` ### Clear metadata for a .docx file -```pycon ->>> TODO +```console +dmeta --clear "./test_a.docx" ``` -### Clear metadata for all existing .docx files -```pycon ->>> TODO +### Clear metadata for all existing .docx files in the current directory +```console +dmeta --clear-all ``` ### Update metadata for a .docx file -```pycon ->>> TODO +```console +dmeta --update "./test_a.docx" --config "./config.json" ``` -### Update metadata for all existing .docx files -```pycon ->>> TODO +### Update metadata for all existing .docx files in the current directory +```console +dmeta --update-all --config "./config.json" ``` - ## Supported files | File format | support | | ---------------- | ---------------- | | Microsoft word office(.docx) | ✅ | - ## Issues & bug reports Just fill an issue and describe it. We'll check it ASAP! or send an email to [info@openscilab.com](mailto:info@openscilab.com "info@openscilab.com"). From 9661aee846632809390fef71a90f020baa5b6476 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Thu, 13 Jun 2024 21:54:49 -0700 Subject: [PATCH 08/10] fix : minor issues fixed in `README.md`. --- CHANGELOG.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ae58b1..1ed8554 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed ## [0.1] - 2024-05-29 ### Added -- `CLI` Handler +- `CLI` handler - `main` function in `__main__.py` - `README.md` - `clear` function `functions.py` diff --git a/README.md b/README.md index 9fa3ac6..1a59695 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ ## Overview

-DMeta is an open source Python package that removes metadata of microsoft office files. +DMeta is an open source Python package that removes metadata of Microsoft Office files.

@@ -105,7 +105,7 @@ from dmeta.functions import update CONFIG_FILE_PATH = os.path.join(os.getcwd(), "CONFIG.json") DOCX_FILE_PATH = os.path.join(os.getcwd(), "SAMPLE.docx") -update(DOCX_FILE_PATH, DOCX_FILE_PATH) +update(CONFIG_FILE_PATH, DOCX_FILE_PATH) ``` ### Update metadata for all existing .docx files in the current directory From 586ebef2427c31582ef666bc8b8fb219e40aa042 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Thu, 13 Jun 2024 22:08:30 -0700 Subject: [PATCH 09/10] update : links and badges updated. --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 1a59695..529a3e5 100644 --- a/README.md +++ b/README.md @@ -5,14 +5,14 @@ Codecov - - PyPI version + + PyPI version built with Python3 - - Discord Channel + + Discord Channel @@ -41,8 +41,8 @@ DMeta is an open source Python package that removes metadata of Microsoft Office @@ -50,7 +50,7 @@ DMeta is an open source Python package that removes metadata of Microsoft Office @@ -154,8 +154,8 @@ Just fill an issue and describe it. We'll check it ASAP! or send an email to [in You can also join our discord server - - Discord Channel + + Discord Channel @@ -169,4 +169,4 @@ Give a ⭐️ if this project helped you! ### Donate to our project If you do like our project and we hope that you do, can you please support us? Our project is not and is never going to be working for profit. We need the money just so we can continue doing what we do ;-) . -DMeta Donation \ No newline at end of file +DMeta Donation From 486a99ae7161ec38cbb32d3f686e90e74eb95270 Mon Sep 17 00:00:00 2001 From: Sadra Sabouri Date: Fri, 14 Jun 2024 06:55:22 -0700 Subject: [PATCH 10/10] update : `README.md` updated. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 529a3e5..9cb1143 100644 --- a/README.md +++ b/README.md @@ -84,13 +84,13 @@ DMeta is an open source Python package that removes metadata of Microsoft Office - Run `pip install .` ## Usage -### Programmatically +### In Python #### Clear metadata for a .docx file ```python import os from dmeta.functions import clear -DOCX_FILE_PATH = os.path.join(os.getcwd(), "SAMPLE.docx") +DOCX_FILE_PATH = os.path.join(os.getcwd(), "sample.docx") clear(DOCX_FILE_PATH) ``` #### Clear metadata for all existing .docx files in the current directory @@ -103,8 +103,8 @@ clear_all() import os from dmeta.functions import update -CONFIG_FILE_PATH = os.path.join(os.getcwd(), "CONFIG.json") -DOCX_FILE_PATH = os.path.join(os.getcwd(), "SAMPLE.docx") +CONFIG_FILE_PATH = os.path.join(os.getcwd(), "config.json") +DOCX_FILE_PATH = os.path.join(os.getcwd(), "sample.docx") update(CONFIG_FILE_PATH, DOCX_FILE_PATH) ``` @@ -113,7 +113,7 @@ update(CONFIG_FILE_PATH, DOCX_FILE_PATH) import os from dmeta.functions import update_all -CONFIG_FILE_PATH = os.path.join(os.getcwd(), "CONFIG.json") +CONFIG_FILE_PATH = os.path.join(os.getcwd(), "config.json") update_all(CONFIG_FILE_PATH) ```
PyPI Counter - - + +
Github Stars - +