diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 90596a5..37f3b01 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,14 +9,14 @@ bandit: script: - apt-get -qqy update - apt-get -qqy install --no-install-recommends python3-bandit - - bandit -r ./src --format txt --skip B404,B603 + - bandit -r ./libmat2 --format txt --skip B404,B603 pyflakes: stage: linting script: - apt-get -qqy update - apt-get -qqy install --no-install-recommends pyflakes3 - - pyflakes3 ./src + - pyflakes3 ./libmat2 tests: stage: test @@ -24,4 +24,4 @@ tests: - apt-get -qqy update - apt-get -qqy install --no-install-recommends python3-mutagen python3-gi-cairo gir1.2-poppler-0.18 gir1.2-gdkpixbuf-2.0 libimage-exiftool-perl python3-coverage - python3-coverage run -m unittest discover -s tests/ - - python3-coverage report -m --include 'src/*' + - python3-coverage report -m --include 'libmat2/*' diff --git a/README.md b/README.md index 51f3c63..0499372 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ $ python3 -m unittest discover -v # Supported formats ```bash -$ python3 ./main.py -l +$ python3 ./mat2.py -l ``` # Related softwares diff --git a/src/__init__.py b/libmat2/__init__.py similarity index 100% rename from src/__init__.py rename to libmat2/__init__.py diff --git a/src/abstract.py b/libmat2/abstract.py similarity index 100% rename from src/abstract.py rename to libmat2/abstract.py diff --git a/src/audio.py b/libmat2/audio.py similarity index 100% rename from src/audio.py rename to libmat2/audio.py diff --git a/src/harmless.py b/libmat2/harmless.py similarity index 100% rename from src/harmless.py rename to libmat2/harmless.py diff --git a/src/images.py b/libmat2/images.py similarity index 100% rename from src/images.py rename to libmat2/images.py diff --git a/src/office.py b/libmat2/office.py similarity index 100% rename from src/office.py rename to libmat2/office.py diff --git a/src/parser_factory.py b/libmat2/parser_factory.py similarity index 86% rename from src/parser_factory.py rename to libmat2/parser_factory.py index 48616b0..dbe68b9 100644 --- a/src/parser_factory.py +++ b/libmat2/parser_factory.py @@ -10,10 +10,10 @@ from . import abstract, unsupported_extensions T = TypeVar('T', bound='abstract.AbstractParser') # This loads every parser in a dynamic way -for module_loader, name, ispkg in pkgutil.walk_packages('.src'): - if not name.startswith('src.'): +for module_loader, name, ispkg in pkgutil.walk_packages('.libmat2'): + if not name.startswith('libmat2.'): continue - elif name == 'src.abstract': + elif name == 'libmat2.abstract': continue importlib.import_module(name) diff --git a/src/pdf.py b/libmat2/pdf.py similarity index 100% rename from src/pdf.py rename to libmat2/pdf.py diff --git a/src/torrent.py b/libmat2/torrent.py similarity index 100% rename from src/torrent.py rename to libmat2/torrent.py diff --git a/main.py b/mat2.py similarity index 98% rename from main.py rename to mat2.py index 55489be..aa213ab 100755 --- a/main.py +++ b/mat2.py @@ -8,7 +8,7 @@ import mimetypes import argparse import multiprocessing -from src import parser_factory, unsupported_extensions +from libmat2 import parser_factory, unsupported_extensions __version__ = '0.1.1' diff --git a/tests/test_climat2.py b/tests/test_climat2.py index 864ee0d..36973bf 100644 --- a/tests/test_climat2.py +++ b/tests/test_climat2.py @@ -6,43 +6,43 @@ import unittest class TestHelp(unittest.TestCase): def test_help(self): - proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) + proc = subprocess.Popen(['./mat2.py', '--help'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) + self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) def test_no_arg(self): - proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) + proc = subprocess.Popen(['./mat2.py'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) + self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) class TestVersion(unittest.TestCase): def test_version(self): - proc = subprocess.Popen(['./main.py', '--version'], stdout=subprocess.PIPE) + proc = subprocess.Popen(['./mat2.py', '--version'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertTrue(stdout.startswith(b'MAT2 ')) class TestExclusiveArgs(unittest.TestCase): def test_version(self): - proc = subprocess.Popen(['./main.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + proc = subprocess.Popen(['./mat2.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout, stderr = proc.communicate() - self.assertIn(b'main.py: error: argument -c/--check: not allowed with argument -s/--show', stderr) + self.assertIn(b'mat2.py: error: argument -c/--check: not allowed with argument -s/--show', stderr) class TestReturnValue(unittest.TestCase): def test_nonzero(self): - ret = subprocess.call(['./main.py', './main.py'], stdout=subprocess.DEVNULL) + ret = subprocess.call(['./mat2.py', './mat2.py'], stdout=subprocess.DEVNULL) self.assertEqual(255, ret) - ret = subprocess.call(['./main.py', '--whololo'], stderr=subprocess.DEVNULL) + ret = subprocess.call(['./mat2.py', '--whololo'], stderr=subprocess.DEVNULL) self.assertEqual(2, ret) def test_zero(self): - ret = subprocess.call(['./main.py'], stdout=subprocess.DEVNULL) + ret = subprocess.call(['./mat2.py'], stdout=subprocess.DEVNULL) self.assertEqual(0, ret) - ret = subprocess.call(['./main.py', '--show', './main.py'], stdout=subprocess.DEVNULL) + ret = subprocess.call(['./mat2.py', '--show', './mat2.py'], stdout=subprocess.DEVNULL) self.assertEqual(0, ret) @@ -50,16 +50,16 @@ class TestCleanMeta(unittest.TestCase): def test_jpg(self): shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') - proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.jpg'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.jpg'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'Comment: Created with GIMP', stdout) - proc = subprocess.Popen(['./main.py', './tests/data/clean.jpg'], + proc = subprocess.Popen(['./mat2.py', './tests/data/clean.jpg'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() - proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.cleaned.jpg'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.cleaned.jpg'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertNotIn(b'Comment: Created with GIMP', stdout) @@ -69,25 +69,25 @@ class TestCleanMeta(unittest.TestCase): class TestGetMeta(unittest.TestCase): def test_pdf(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.pdf'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.pdf'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'producer: pdfTeX-1.40.14', stdout) def test_png(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.png'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.png'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'Comment: This is a comment, be careful!', stdout) def test_jpg(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.jpg'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.jpg'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'Comment: Created with GIMP', stdout) def test_docx(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.docx'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.docx'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout) @@ -95,7 +95,7 @@ class TestGetMeta(unittest.TestCase): self.assertIn(b'revision: 1', stdout) def test_odt(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.odt'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.odt'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) @@ -103,14 +103,14 @@ class TestGetMeta(unittest.TestCase): self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) def test_mp3(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.mp3'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.mp3'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'TALB: harmfull', stdout) self.assertIn(b'COMM::: Thank you for using MAT !', stdout) def test_flac(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.flac'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.flac'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'comments: Thank you for using MAT !', stdout) @@ -118,7 +118,7 @@ class TestGetMeta(unittest.TestCase): self.assertIn(b'title: I am so', stdout) def test_ogg(self): - proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.ogg'], + proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.ogg'], stdout=subprocess.PIPE) stdout, _ = proc.communicate() self.assertIn(b'comments: Thank you for using MAT !', stdout) diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index f3e11d9..89a5811 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -6,7 +6,7 @@ import os import zipfile import tempfile -from src import pdf, images, audio, office, parser_factory, torrent +from libmat2 import pdf, images, audio, office, parser_factory, torrent class TestParserFactory(unittest.TestCase):