Skip to content

Commit

Permalink
Merge pull request #61 from ganeshhubale/fix-table
Browse files Browse the repository at this point in the history
Fixed table print issue
  • Loading branch information
mayurilahane authored Feb 9, 2020
2 parents c09ae48 + db02964 commit 01bedac
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 79 deletions.
51 changes: 26 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,29 @@ jobs:
if: failure()
run: git diff

tests:
name: Test-${{ matrix.os }}-Py${{ matrix.python-version }}
needs: pre-commit
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: [ '3.6', '3.7' ]
steps:
- name: Checkout to master
uses: actions/checkout@master

- name: Setup Python-${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Setup Package
run: python -m pip install .

- name: Unit Tests
run: |
python -m pip install pytest
py.test -v
# For future use
# tests:
# name: Test-${{ matrix.os }}-Py${{ matrix.python-version }}
# needs: pre-commit
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, windows-latest, macos-latest]
# python-version: [ '3.6', '3.7' ]
# steps:
# - name: Checkout to master
# uses: actions/checkout@master
#
# - name: Setup Python-${{ matrix.python-version }}
# uses: actions/setup-python@v1
# with:
# python-version: ${{ matrix.python-version }}
# architecture: x64
#
# - name: Setup Package
# run: python -m pip install .
#
# - name: Unit Tests
# run: |
# python -m pip install pytest
# py.test -v
12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

11 changes: 2 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ PyGenpass - Command Line Password Generator and Manager Tool

How to run project?
===================


* Create a virtual environment on your local machine

.. code-block:: bash
Expand All @@ -27,22 +25,19 @@ How to run project?
$ git clone https://github.com/paint-it/pygenpass.git
* Install using pip or setup.py

* Install setup.py or install using pip

.. code-block:: bash
$ pip install pygenpass
$ python3 setup.py install
* Use command **pygenpass**

Command line options
====================

.. code-block:: bash
$ pygenpass
Expand All @@ -62,7 +57,6 @@ Command line options
Examples
========

* This command will ask for portal name and will create random password

.. code-block:: bash
Expand Down Expand Up @@ -107,5 +101,4 @@ Dependencies

How to contribute to this project?
==================================

* Please read `contributing.md <https://github.com/paint-it/pygenpass/blob/master/contributing.md>`_
15 changes: 4 additions & 11 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# Steps to contribute:
# Steps to contribute:
* Fork this project on your GitHub account

* Create virtual environment on your local machine
```nashorn js
$ python3 -m venv env
```
* Activate virtual environment
```
* Activate virtual environment
```nashorn js
$ source env/bin/activate
```
* Make a local directory

* Clone project in your directory
```nashorn js
$ git clone https://github.com/paint-it/pygenpass.git
```

* Update with your changes and install project locally using **setup.py** file
```nashorn js
$ python3 setup.py install
```
* After successful installation; try **pygenpass** command
* After successful installation; try **pygenpass** command
* Commit this changes and make a PR
* Be a part of **PyGenpass!!!**
8 changes: 4 additions & 4 deletions pygenpass/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import click

from pygenpass.password import allpass
from pygenpass.password import createpass
from pygenpass.password import delpass
from pygenpass.password import modpass
from pygenpass.password import savepass
from pygenpass.password import showpass
from pygenpass.password import delpass
from pygenpass.password import version
from pygenpass.password import modpass
from pygenpass.password import allpass


@click.group()
Expand Down
13 changes: 6 additions & 7 deletions pygenpass/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import sqlite3 # library for database


Expand All @@ -32,10 +31,10 @@ def __init__(self):
self.con = sqlite3.connect("generated_password.db")
self.cursor_obj = self.con.cursor()
self.cursor_obj.execute(
"""CREATE TABLE IF NOT EXISTS passwords
(id integer PRIMARY KEY,portal_name text NOT NULL UNIQUE, password varchar,
creation_date varchar, email varchar, portal_url varchar)
"""
"""CREATE TABLE IF NOT EXISTS passwords(
id integer PRIMARY KEY,portal_name text NOT NULL UNIQUE, password varchar,
creation_date varchar, email varchar, portal_url varchar)
"""
)
self.con.commit()

Expand All @@ -50,7 +49,7 @@ def insert_data(self, portal_name, password, creation_date, email, portal_url):
"""INSERT INTO passwords
(portal_name, password, creation_date, email, portal_url)
VALUES (?, ?, ?, ?, ?)""",
(self.portal_name, self.password, self.creation_date, self.email, self.portal_url,),
(self.portal_name, self.password, self.creation_date, self.email, self.portal_url),
)
self.con.commit()

Expand All @@ -76,7 +75,7 @@ def show_data(self, portal_name):
"""All inserted data will showed"""
self.portal_name = portal_name
self.cursor_obj.execute(
"""SELECT password FROM passwords WHERE portal_name=?""", (self.portal_name,),
"""SELECT password FROM passwords WHERE portal_name=?""", (self.portal_name,)
)
rows = self.cursor_obj.fetchall()

Expand Down
23 changes: 12 additions & 11 deletions pygenpass/password.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
import click # Used for command line interface
import diceware # Used for creating password
from pygenpass.database import DatabaseConnection
from datetime import date
from beautifultable import BeautifulTable # display output in table format

import click
import diceware
from beautifultable import BeautifulTable

from pygenpass.database import DatabaseConnection

db_obj = DatabaseConnection()
table = BeautifulTable()
table.left_border_char = "|"
table.right_border_char = "|"
table.top_border_char = "="
table.header_separator_char = "="
table.column_headers = ["ID", "PORTAL_NAME", "PASSWORD", "DATE", "EMAIL", "PORTAL_URL"]


@click.command(help="Show Version")
Expand All @@ -39,15 +46,9 @@ def allpass():
all_pass = db_obj.show_all_data()
if all_pass == []:
print("No records found")
table = BeautifulTable()
table.left_border_char = "|"
table.right_border_char = "|"
table.top_border_char = "="
table.header_separator_char = "="
table.column_headers = ["ID", "PORTAL_NAME", "PASSWORD", "DATE", "EMAIL", "PORTAL_URL"]
for row in all_pass:
table.append_row([row[0], row[1], row[2], row[3], row[4], row[5]])
print(table)
print(table)


@click.command(help="Delete password")
Expand Down

0 comments on commit 01bedac

Please sign in to comment.