Skip to content

Commit

Permalink
Merge 9ad52ea into staging
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Jun 20, 2021
2 parents bd4ac3c + 9ad52ea commit 0a9d79c
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 71 deletions.
88 changes: 44 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,47 +64,47 @@ jobs:
target_branch: staging
github_token: ${{ github.token }}

# to-master:
# # if the commit message was "publish", copy the tested code
# # to "master" branch and create GitHub release
#
# if: github.event.head_commit.message=='publish'
# needs: [ test ]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
#
# # UPDATE MASTER BRANCH
# - name: Merge to master branch
# uses: devmasx/merge-branch@v1.3.1
# with:
# type: now
# target_branch: master
# github_token: ${{ github.token }}
#
# # ADD GITHUB RELEASE
# - name: Get the Python package version
# run: echo "PKGVER=$(python setup.py --version)" >> $GITHUB_ENV
# - name: Publish GitHub release
# uses: softprops/action-gh-release@v1
# with:
# tag_name: ${{ env.PKGVER }}
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
# # ADD PYPI RELEASE
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: '3.x'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install setuptools wheel twine
# - name: Build and publish
# env:
# TWINE_USERNAME: ${{ secrets.PYPI_USR }}
# TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
# run: |
# python setup.py sdist bdist_wheel
# twine upload dist/*
to-master:
# if the commit message was "publish", copy the tested code
# to "master" branch and create GitHub release

if: github.event.head_commit.message=='publish'
needs: [ test ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

# UPDATE MASTER BRANCH
- name: Merge to master branch
uses: devmasx/merge-branch@v1.3.1
with:
type: now
target_branch: master
github_token: ${{ github.token }}

# ADD GITHUB RELEASE
- name: Get the Python package version
run: echo "PKGVER=$(python setup.py --version)" >> $GITHUB_ENV
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.PKGVER }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# ADD PYPI RELEASE
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USR }}
TWINE_PASSWORD: ${{ secrets.PYPI_PWD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[![Generic badge](https://img.shields.io/badge/Status-Experimental-red.svg)](#)
[![Generic badge](https://img.shields.io/badge/Status-Pre_Alpha-red.svg)](#)
[![Generic badge](https://img.shields.io/badge/Python-3.7+-blue.svg)](#)
[![Generic badge](https://img.shields.io/badge/OS-Linux%20|%20macOS%20|%20Windows-blue.svg)](#)

**This is experimental code. It is not ready to use. This description is also a
draft.**
**This is experimental code. The file format may change.**

# [dmk: dark matter keeper](https://github.com/rtmigo/dmk_py#readme)

Expand Down Expand Up @@ -112,36 +111,40 @@ By default, it is `vault.dmk` in the current user's `$HOME` directory.
The `-v` parameter overrides the location for a single run.

```
$ dmk -v /path/to/file.data vault
$ dmk -v /path/to/myfile.data vault
```

Output:
```
/path/to/file.data
/path/to/myfile.data
```

The parameter can be used with any commands:

```
$ dmk -v /path/to/file.data set
$ dmk -v /path/to/file.data get
$ dmk -v /path/to/myfile.data set
$ dmk -v /path/to/myfile.data get
```

--------------------------------------------------------------------------------

The `$DMK_VAULT_FILE` environment variable overrides the default location:

```
$ export DMK_VAULT_FILE=/path/to/file.data
$ export DMK_VAULT_FILE=/path/to/myfile.data
$ dmk vault
```
Output:
```
/path/to/file.data
/path/to/myfile.data
```

While `$DMK_VAULT_FILE` is set all the command will use `myfile.data`:


```
$ dmk set # set to myfile.data
$ dmk get # get from myfile.data
```

# Under the hood

Expand Down
16 changes: 9 additions & 7 deletions dmk/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
VAULT_ARG_LONG = "--vault"


def validate_filename(ctx, param, value):
if value is None or not value.strip():
raise click.BadParameter("Storage filename must be specified")
return value
# def validate_filename(ctx, param, value):
# if value is None or not value.strip():
# raise click.BadParameter("Storage filename must be specified")
# return value


class Globals:
Expand All @@ -48,10 +48,12 @@ def the_main(cls) -> Main:
@click.option(VAULT_ARG_SHORT, VAULT_ARG_LONG,
envvar=VAULT_FILE_ENVNAME,
default=DEFAULT_STORAGE_FILE,
callback=validate_filename)
type=Path,
#callback=validate_filename
)
@click.pass_context
def dmk_cli(ctx, vault):
Globals.main = Main(vault)
def dmk_cli(ctx, vault: Path):
Globals.main = Main(vault) # todo
if not ctx.invoked_subcommand:
click.echo(f"DMK: Dark Matter Keeper v{__version__}")
print('(c) 2021 Artem IG <ortemeo@gmail.com>')
Expand Down
12 changes: 5 additions & 7 deletions dmk/_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ def __init__(self):


class Main:
def __init__(self, storage_file: str):
def __init__(self, storage_file: Path):

if not storage_file:
raise ValueError
str_path = str(storage_file)
str_path = os.path.expanduser(str_path)
str_path = os.path.expandvars(str_path)

storage_file = os.path.expanduser(storage_file)
storage_file = os.path.expandvars(storage_file)

self.file_path = Path(storage_file) # stub
self.file_path = Path(str_path)

def set_text(self, name: str, value: str):
crd = TheFile(self.file_path)
Expand Down
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ def load_module_dict(filename: str) -> dict:

author="Artëm IG",
author_email="ortemeo@gmail.com",
# url='https://github.com/rtmigo/vien_py',
url='https://github.com/rtmigo/dmk_py',

packages=find_packages(include='dmk/*'),
python_requires='>=3.7',
install_requires=['pycryptodome', 'click', 'argon2-cffi'],

description="Experimental",
description="Experimental storage where each entry is encrypted with "
"its own key.",

long_description=readme,
long_description_content_type='text/markdown',
Expand All @@ -47,15 +48,17 @@ def load_module_dict(filename: str) -> dict:
classifiers=[
#"Development Status :: 4 - Beta",
#"Intended Audience :: Developers",
'Development Status :: 2 - Pre-Alpha',
'License :: OSI Approved :: BSD License',
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
'Topic :: Security :: Cryptography',
"Environment :: Console",
"Typing :: Typed",
#"Topic :: Software Development :: Build Tools",
"Operating System :: POSIX",
# "Operating System :: Microsoft :: Windows"
"Operating System :: Microsoft :: Windows"
],

test_suite="test_unit.suite"
Expand Down

0 comments on commit 0a9d79c

Please sign in to comment.