Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancements #29

Merged
merged 10 commits into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ 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"
ls ./tests
- name: CLI Tests - Clear all .docx files
run: |
cd ./tests
dmeta --clear-all
ls .
cd -
- name: CLI Tests - Update single .docx file
run: |
dmeta --update "tests/test_a.docx" --config "tests/config.json"
ls ./tests
- name: CLI Tests - Update all .docx files
run: |
cd ./tests
dmeta --update-all --config "./config.json"
ls .
cd -
- name: Test requirements Installation
run: |
python otherfiles/requirements-splitter.py
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
84 changes: 61 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<a href="https://codecov.io/gh/openscilab/dmeta">
<img src="https://codecov.io/gh/openscilab/dmeta/branch/main/graph/badge.svg" alt="Codecov"/>
</a>
<a href="TODO">
<img src="TODO" alt="PyPI version" height="18">
<a href="https://badge.fury.io/py/dmeta">
<img src="https://badge.fury.io/py/dmeta.svg" alt="PyPI version" height="18">
</a>
<a href="https://www.python.org/">
<img src="https://img.shields.io/badge/built%20with-Python3-green.svg" alt="built with Python3">
</a>
<a href="TODO">
<img src="TODO" alt="Discord Channel">
<a href="https://discord.gg/626twyuPZG">
<img src="https://img.shields.io/discord/1064533716615049236.svg" alt="Discord Channel">
</a>
</div>

Expand All @@ -35,22 +35,22 @@

## Overview
<p align="justify">
DMeta is an open source Python package that provides ... TODO
DMeta is an open source Python package that removes metadata of Microsoft Office files.
</p>
<table>
<tr>
<td align="center">PyPI Counter</td>
<td align="center">
<a href="TODO">
<img src="TODO">
<a href="http://pepy.tech/project/dmeta">
<img src="http://pepy.tech/badge/dmeta">
</a>
</td>
</tr>
<tr>
<td align="center">Github Stars</td>
<td align="center">
<a href="https://github.com/openscilab/dmeta">
<img src="TODO">
<img src="https://img.shields.io/github/stars/openscilab/dmeta.svg?style=social&label=Stars">
</a>
</td>
</tr>
Expand Down Expand Up @@ -84,30 +84,68 @@ DMeta is an open source Python package that provides ... TODO
- Run `pip install .`

## Usage
### 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")
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(CONFIG_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) | &#x2705; |


## Issues & bug reports

Just fill an issue and describe it. We'll check it ASAP! or send an email to [[email protected]](mailto:[email protected] "[email protected]").
Expand All @@ -116,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

<a href="TODO">
<img src="TODO" alt="Discord Channel">
<a href="https://discord.gg/626twyuPZG">
<img src="https://img.shields.io/discord/1064533716615049236.svg?style=for-the-badge" alt="Discord Channel">
</a>


Expand All @@ -131,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 ;-) .

<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/dmeta/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="DMeta Donation"></a>
<a href="https://openscilab.com/#donation" target="_blank"><img src="https://github.com/openscilab/dmeta/raw/main/otherfiles/donation.png" height="90px" width="270px" alt="DMeta Donation"></a>
20 changes: 7 additions & 13 deletions dmeta/__main__.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -11,9 +10,6 @@ def main():

:return: None
"""
tprint("DMeta")
tprint("V:" + DMETA_VERSION)
dmeta_help()
parser = argparse.ArgumentParser()
parser.add_argument(
'--clear',
Expand Down Expand Up @@ -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"
7 changes: 6 additions & 1 deletion dmeta/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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()
Loading