Skip to content

Commit

Permalink
Added is_signed(), parse_changes(), verify_signature().
Browse files Browse the repository at this point in the history
Signed-off-by: Kouhei Maeda <mkouhei@palmtb.net>
  • Loading branch information
mkouhei committed May 23, 2014
1 parent 5a841d2 commit a359bac
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
14 changes: 11 additions & 3 deletions pydebsign/debsign.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""
import hashlib
import gnupg
import deb822


class Debsign(object):
Expand All @@ -24,14 +25,20 @@ def is_signed(self, file_path):
Returns: `bool` True is signed, False is unsigned.
:param file_path: expecting .dsc file or .changes file.
"""
pass
with open(file_path, 'rb') as fileobj:
if self.gpg.verify(fileobj.read()).status is None:
return False
else:
return True

def parse_changes(self, changes_path):
""" parse .changes and retrieve efile size and file name list.
Returns: file list with file size and checksums.
:param changes_path: .changes file path
"""
pass
with open(changes_path, 'rb') as fileobj:
changes = deb822.Changes(fileobj)
return [_file for _file in changes['Files']]

def retrieve_dsc_path(self, file_list):
""" retrieve dsc file path from file list.
Expand Down Expand Up @@ -103,7 +110,8 @@ def verify_signature(self, file_path):
Returns: `bool` True is valid, False is invalid
:param file_path: expecting .dsc file path or .changes file path
"""
pass
with open(file_path) as fileobj:
return self.gpg.verify(fileobj.read()).valid

def verify_with_dput(self, changes_path):
""" verify .changes and .dsc files with `dput` command.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
python_gnupg
python_debian
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ def run_tests(self):
open(os.path.join("docs", "TODO.rst")).read())

requires = ['setuptools',
'python_gnupg']
'python_gnupg',
'python_debian']

setup(name='pydebsign',
version='0.1.0',
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ commands =
[py]
deps=
python_gnupg
python_debian
pep8
coverage
pytest
Expand Down

0 comments on commit a359bac

Please sign in to comment.