summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2018-05-18 23:52:40 +0200
committerjvoisin2018-05-18 23:52:40 +0200
commit38fae60b8beaf9c7b37c65325d2d285e62b6cb85 (patch)
treee6bd4f699d6190dfada7618ebd04455eb7de9660
parent57d5cd04284276c49899034a9ad321b680624d8f (diff)
Rename some files to simplify packaging
- the `src` folder is now `libmat2` - the `main.py` script is now `mat2.py`
Diffstat (limited to '')
-rw-r--r--.gitlab-ci.yml6
-rw-r--r--README.md2
-rw-r--r--libmat2/__init__.py (renamed from src/__init__.py)0
-rw-r--r--libmat2/abstract.py (renamed from src/abstract.py)0
-rw-r--r--libmat2/audio.py (renamed from src/audio.py)0
-rw-r--r--libmat2/harmless.py (renamed from src/harmless.py)0
-rw-r--r--libmat2/images.py (renamed from src/images.py)0
-rw-r--r--libmat2/office.py (renamed from src/office.py)0
-rw-r--r--libmat2/parser_factory.py (renamed from src/parser_factory.py)6
-rw-r--r--libmat2/pdf.py (renamed from src/pdf.py)0
-rw-r--r--libmat2/torrent.py (renamed from src/torrent.py)0
-rwxr-xr-xmat2.py (renamed from main.py)2
-rw-r--r--tests/test_climat2.py44
-rw-r--r--tests/test_libmat2.py2
14 files changed, 31 insertions, 31 deletions
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:
9 script: 9 script:
10 - apt-get -qqy update 10 - apt-get -qqy update
11 - apt-get -qqy install --no-install-recommends python3-bandit 11 - apt-get -qqy install --no-install-recommends python3-bandit
12 - bandit -r ./src --format txt --skip B404,B603 12 - bandit -r ./libmat2 --format txt --skip B404,B603
13 13
14pyflakes: 14pyflakes:
15 stage: linting 15 stage: linting
16 script: 16 script:
17 - apt-get -qqy update 17 - apt-get -qqy update
18 - apt-get -qqy install --no-install-recommends pyflakes3 18 - apt-get -qqy install --no-install-recommends pyflakes3
19 - pyflakes3 ./src 19 - pyflakes3 ./libmat2
20 20
21tests: 21tests:
22 stage: test 22 stage: test
@@ -24,4 +24,4 @@ tests:
24 - apt-get -qqy update 24 - apt-get -qqy update
25 - 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 25 - 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
26 - python3-coverage run -m unittest discover -s tests/ 26 - python3-coverage run -m unittest discover -s tests/
27 - python3-coverage report -m --include 'src/*' 27 - 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
47# Supported formats 47# Supported formats
48 48
49```bash 49```bash
50$ python3 ./main.py -l 50$ python3 ./mat2.py -l
51``` 51```
52 52
53# Related softwares 53# Related softwares
diff --git a/src/__init__.py b/libmat2/__init__.py
index 07d3036..07d3036 100644
--- a/src/__init__.py
+++ b/libmat2/__init__.py
diff --git a/src/abstract.py b/libmat2/abstract.py
index e4838a9..e4838a9 100644
--- a/src/abstract.py
+++ b/libmat2/abstract.py
diff --git a/src/audio.py b/libmat2/audio.py
index 3a6aa79..3a6aa79 100644
--- a/src/audio.py
+++ b/libmat2/audio.py
diff --git a/src/harmless.py b/libmat2/harmless.py
index aa00582..aa00582 100644
--- a/src/harmless.py
+++ b/libmat2/harmless.py
diff --git a/src/images.py b/libmat2/images.py
index c84952a..c84952a 100644
--- a/src/images.py
+++ b/libmat2/images.py
diff --git a/src/office.py b/libmat2/office.py
index 749fc7d..749fc7d 100644
--- a/src/office.py
+++ b/libmat2/office.py
diff --git a/src/parser_factory.py b/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
10T = TypeVar('T', bound='abstract.AbstractParser') 10T = TypeVar('T', bound='abstract.AbstractParser')
11 11
12# This loads every parser in a dynamic way 12# This loads every parser in a dynamic way
13for module_loader, name, ispkg in pkgutil.walk_packages('.src'): 13for module_loader, name, ispkg in pkgutil.walk_packages('.libmat2'):
14 if not name.startswith('src.'): 14 if not name.startswith('libmat2.'):
15 continue 15 continue
16 elif name == 'src.abstract': 16 elif name == 'libmat2.abstract':
17 continue 17 continue
18 importlib.import_module(name) 18 importlib.import_module(name)
19 19
diff --git a/src/pdf.py b/libmat2/pdf.py
index 5b99192..5b99192 100644
--- a/src/pdf.py
+++ b/libmat2/pdf.py
diff --git a/src/torrent.py b/libmat2/torrent.py
index cb4b5e3..cb4b5e3 100644
--- a/src/torrent.py
+++ b/libmat2/torrent.py
diff --git a/main.py b/mat2.py
index 55489be..aa213ab 100755
--- a/main.py
+++ b/mat2.py
@@ -8,7 +8,7 @@ import mimetypes
8import argparse 8import argparse
9import multiprocessing 9import multiprocessing
10 10
11from src import parser_factory, unsupported_extensions 11from libmat2 import parser_factory, unsupported_extensions
12 12
13__version__ = '0.1.1' 13__version__ = '0.1.1'
14 14
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
6 6
7class TestHelp(unittest.TestCase): 7class TestHelp(unittest.TestCase):
8 def test_help(self): 8 def test_help(self):
9 proc = subprocess.Popen(['./main.py', '--help'], stdout=subprocess.PIPE) 9 proc = subprocess.Popen(['./mat2.py', '--help'], stdout=subprocess.PIPE)
10 stdout, _ = proc.communicate() 10 stdout, _ = proc.communicate()
11 self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) 11 self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout)
12 12
13 def test_no_arg(self): 13 def test_no_arg(self):
14 proc = subprocess.Popen(['./main.py'], stdout=subprocess.PIPE) 14 proc = subprocess.Popen(['./mat2.py'], stdout=subprocess.PIPE)
15 stdout, _ = proc.communicate() 15 stdout, _ = proc.communicate()
16 self.assertIn(b'usage: main.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout) 16 self.assertIn(b'usage: mat2.py [-h] [-v] [-l] [-c | -s | -L] [files [files ...]]', stdout)
17 17
18 18
19class TestVersion(unittest.TestCase): 19class TestVersion(unittest.TestCase):
20 def test_version(self): 20 def test_version(self):
21 proc = subprocess.Popen(['./main.py', '--version'], stdout=subprocess.PIPE) 21 proc = subprocess.Popen(['./mat2.py', '--version'], stdout=subprocess.PIPE)
22 stdout, _ = proc.communicate() 22 stdout, _ = proc.communicate()
23 self.assertTrue(stdout.startswith(b'MAT2 ')) 23 self.assertTrue(stdout.startswith(b'MAT2 '))
24 24
25 25
26class TestExclusiveArgs(unittest.TestCase): 26class TestExclusiveArgs(unittest.TestCase):
27 def test_version(self): 27 def test_version(self):
28 proc = subprocess.Popen(['./main.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 28 proc = subprocess.Popen(['./mat2.py', '-s', '-c'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
29 stdout, stderr = proc.communicate() 29 stdout, stderr = proc.communicate()
30 self.assertIn(b'main.py: error: argument -c/--check: not allowed with argument -s/--show', stderr) 30 self.assertIn(b'mat2.py: error: argument -c/--check: not allowed with argument -s/--show', stderr)
31 31
32 32
33class TestReturnValue(unittest.TestCase): 33class TestReturnValue(unittest.TestCase):
34 def test_nonzero(self): 34 def test_nonzero(self):
35 ret = subprocess.call(['./main.py', './main.py'], stdout=subprocess.DEVNULL) 35 ret = subprocess.call(['./mat2.py', './mat2.py'], stdout=subprocess.DEVNULL)
36 self.assertEqual(255, ret) 36 self.assertEqual(255, ret)
37 37
38 ret = subprocess.call(['./main.py', '--whololo'], stderr=subprocess.DEVNULL) 38 ret = subprocess.call(['./mat2.py', '--whololo'], stderr=subprocess.DEVNULL)
39 self.assertEqual(2, ret) 39 self.assertEqual(2, ret)
40 40
41 def test_zero(self): 41 def test_zero(self):
42 ret = subprocess.call(['./main.py'], stdout=subprocess.DEVNULL) 42 ret = subprocess.call(['./mat2.py'], stdout=subprocess.DEVNULL)
43 self.assertEqual(0, ret) 43 self.assertEqual(0, ret)
44 44
45 ret = subprocess.call(['./main.py', '--show', './main.py'], stdout=subprocess.DEVNULL) 45 ret = subprocess.call(['./mat2.py', '--show', './mat2.py'], stdout=subprocess.DEVNULL)
46 self.assertEqual(0, ret) 46 self.assertEqual(0, ret)
47 47
48 48
@@ -50,16 +50,16 @@ class TestCleanMeta(unittest.TestCase):
50 def test_jpg(self): 50 def test_jpg(self):
51 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg') 51 shutil.copy('./tests/data/dirty.jpg', './tests/data/clean.jpg')
52 52
53 proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.jpg'], 53 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.jpg'],
54 stdout=subprocess.PIPE) 54 stdout=subprocess.PIPE)
55 stdout, _ = proc.communicate() 55 stdout, _ = proc.communicate()
56 self.assertIn(b'Comment: Created with GIMP', stdout) 56 self.assertIn(b'Comment: Created with GIMP', stdout)
57 57
58 proc = subprocess.Popen(['./main.py', './tests/data/clean.jpg'], 58 proc = subprocess.Popen(['./mat2.py', './tests/data/clean.jpg'],
59 stdout=subprocess.PIPE) 59 stdout=subprocess.PIPE)
60 stdout, _ = proc.communicate() 60 stdout, _ = proc.communicate()
61 61
62 proc = subprocess.Popen(['./main.py', '--show', './tests/data/clean.cleaned.jpg'], 62 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/clean.cleaned.jpg'],
63 stdout=subprocess.PIPE) 63 stdout=subprocess.PIPE)
64 stdout, _ = proc.communicate() 64 stdout, _ = proc.communicate()
65 self.assertNotIn(b'Comment: Created with GIMP', stdout) 65 self.assertNotIn(b'Comment: Created with GIMP', stdout)
@@ -69,25 +69,25 @@ class TestCleanMeta(unittest.TestCase):
69 69
70class TestGetMeta(unittest.TestCase): 70class TestGetMeta(unittest.TestCase):
71 def test_pdf(self): 71 def test_pdf(self):
72 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.pdf'], 72 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.pdf'],
73 stdout=subprocess.PIPE) 73 stdout=subprocess.PIPE)
74 stdout, _ = proc.communicate() 74 stdout, _ = proc.communicate()
75 self.assertIn(b'producer: pdfTeX-1.40.14', stdout) 75 self.assertIn(b'producer: pdfTeX-1.40.14', stdout)
76 76
77 def test_png(self): 77 def test_png(self):
78 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.png'], 78 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.png'],
79 stdout=subprocess.PIPE) 79 stdout=subprocess.PIPE)
80 stdout, _ = proc.communicate() 80 stdout, _ = proc.communicate()
81 self.assertIn(b'Comment: This is a comment, be careful!', stdout) 81 self.assertIn(b'Comment: This is a comment, be careful!', stdout)
82 82
83 def test_jpg(self): 83 def test_jpg(self):
84 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.jpg'], 84 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.jpg'],
85 stdout=subprocess.PIPE) 85 stdout=subprocess.PIPE)
86 stdout, _ = proc.communicate() 86 stdout, _ = proc.communicate()
87 self.assertIn(b'Comment: Created with GIMP', stdout) 87 self.assertIn(b'Comment: Created with GIMP', stdout)
88 88
89 def test_docx(self): 89 def test_docx(self):
90 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.docx'], 90 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.docx'],
91 stdout=subprocess.PIPE) 91 stdout=subprocess.PIPE)
92 stdout, _ = proc.communicate() 92 stdout, _ = proc.communicate()
93 self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout) 93 self.assertIn(b'Application: LibreOffice/5.4.5.1$Linux_X86_64', stdout)
@@ -95,7 +95,7 @@ class TestGetMeta(unittest.TestCase):
95 self.assertIn(b'revision: 1', stdout) 95 self.assertIn(b'revision: 1', stdout)
96 96
97 def test_odt(self): 97 def test_odt(self):
98 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.odt'], 98 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.odt'],
99 stdout=subprocess.PIPE) 99 stdout=subprocess.PIPE)
100 stdout, _ = proc.communicate() 100 stdout, _ = proc.communicate()
101 self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout) 101 self.assertIn(b'generator: LibreOffice/3.3$Unix', stdout)
@@ -103,14 +103,14 @@ class TestGetMeta(unittest.TestCase):
103 self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout) 103 self.assertIn(b'date_time: 2011-07-26 02:40:16', stdout)
104 104
105 def test_mp3(self): 105 def test_mp3(self):
106 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.mp3'], 106 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.mp3'],
107 stdout=subprocess.PIPE) 107 stdout=subprocess.PIPE)
108 stdout, _ = proc.communicate() 108 stdout, _ = proc.communicate()
109 self.assertIn(b'TALB: harmfull', stdout) 109 self.assertIn(b'TALB: harmfull', stdout)
110 self.assertIn(b'COMM::: Thank you for using MAT !', stdout) 110 self.assertIn(b'COMM::: Thank you for using MAT !', stdout)
111 111
112 def test_flac(self): 112 def test_flac(self):
113 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.flac'], 113 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.flac'],
114 stdout=subprocess.PIPE) 114 stdout=subprocess.PIPE)
115 stdout, _ = proc.communicate() 115 stdout, _ = proc.communicate()
116 self.assertIn(b'comments: Thank you for using MAT !', stdout) 116 self.assertIn(b'comments: Thank you for using MAT !', stdout)
@@ -118,7 +118,7 @@ class TestGetMeta(unittest.TestCase):
118 self.assertIn(b'title: I am so', stdout) 118 self.assertIn(b'title: I am so', stdout)
119 119
120 def test_ogg(self): 120 def test_ogg(self):
121 proc = subprocess.Popen(['./main.py', '--show', './tests/data/dirty.ogg'], 121 proc = subprocess.Popen(['./mat2.py', '--show', './tests/data/dirty.ogg'],
122 stdout=subprocess.PIPE) 122 stdout=subprocess.PIPE)
123 stdout, _ = proc.communicate() 123 stdout, _ = proc.communicate()
124 self.assertIn(b'comments: Thank you for using MAT !', stdout) 124 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
6import zipfile 6import zipfile
7import tempfile 7import tempfile
8 8
9from src import pdf, images, audio, office, parser_factory, torrent 9from libmat2 import pdf, images, audio, office, parser_factory, torrent
10 10
11 11
12class TestParserFactory(unittest.TestCase): 12class TestParserFactory(unittest.TestCase):