-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1130cef
commit d2ad9c9
Showing
12 changed files
with
173 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Poly14/ | ||
Poly18/ | ||
.idea | ||
__pycache__ | ||
venv | ||
TESTCSV/ | ||
TESTXLSX.xlsx | ||
export/ | ||
export_csv/ | ||
export_html/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
language: python | ||
python: | ||
- "3.7" | ||
|
||
install: | ||
- pip install -r requirements.txt | ||
|
||
script: | ||
- pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python3 | ||
|
||
""" Nom du module: RTFReader | ||
Description: Ce module permet la lecture d'un RTF et l'extraction des | ||
tableaux qu'il contient. | ||
Version: 1 | ||
Date: 9 avril 2019 | ||
Auteur: Louis MARTIN | ||
Methodes et classes publiques: | ||
- HTMLReader | ||
__init__(filename, version=18) | ||
get_all_tables() | ||
""" | ||
|
||
# __________________________ IMPORT __________________________ | ||
import HTMLReader | ||
from striprtf.striprtf import rtf_to_text | ||
|
||
# ________________________ CONSTANTES ________________________ | ||
|
||
HTMLReader.CHAR_BEGIN_CHAPTER = "Chapter" | ||
HTMLReader.CHAR_BEGIN_TABLE = "Table" | ||
HTMLReader.CHAR_SECTION = "## " | ||
HTMLReader.SEPARATOR_CELL = "|" | ||
HTMLReader.SEPARATOR_HEADER_LINE = "|" | ||
HTMLReader.SEPARATOR_SUB_CELL = "NO_SUBCELL_POSSIBLE" | ||
HTMLReader.PIPE = "|" | ||
HTMLReader.PIPE_ESCAPED = "PIPE" | ||
|
||
|
||
# __________________ Definition de classes ___________________ | ||
class RTFReader(HTMLReader.HTMLReader): | ||
def __init__(self, filename, version=None): | ||
super().__init__(filename, version=version) | ||
|
||
def _read_lines(self): | ||
lines = "" | ||
for line in self._file.readlines(): | ||
lines = lines + line + "\n" | ||
|
||
|
||
|
||
|
||
|
||
lines = lines.replace(HTMLReader.PIPE, HTMLReader.PIPE_ESCAPED) | ||
|
||
self._lines = rtf_to_text(lines).split("\n") | ||
|
||
|
||
|
||
|
||
def _detect_end_table(self, line): | ||
return not self._lines[line].strip() | ||
|
||
def _detect_begin_table(self, line): | ||
return line+1<len(self._lines) and HTMLReader.CHAR_BEGIN_TABLE in self._lines[line+1] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
XlsxWriter | ||
html2text | ||
striprtf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def test(): | ||
assert(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import os,sys | ||
sys.path.insert(0, os.path.abspath(".")) | ||
sys.path.insert(0, os.path.abspath("..")) | ||
print(sys.path) | ||
|
||
from exportcsv import Exportcsv | ||
|
||
def test_export(): | ||
exporter = Exportcsv("TESTCSV") | ||
data = [["A1", "A2", "A3"], ["B1", "B2", "B3"]] | ||
exporter.add_sheet("EXPORT", data) | ||
assert(os.path.exists("TESTCSV/EXPORT.csv")) | ||
|
||
export = open("TESTCSV/EXPORT.csv"); | ||
csv = [line.replace("\n", "").split(";") for line in export.readlines()] | ||
assert(data == csv) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import os,sys | ||
sys.path.insert(0, os.path.abspath(".")) | ||
sys.path.insert(0, os.path.abspath("..")) | ||
print(sys.path) | ||
|
||
from exportxlsx import Exportxlsx | ||
|
||
def test_export(): | ||
exporter = Exportxlsx("TESTXLSX") | ||
data = [["A1", "A2", "A3"], ["B1", "B2", "B3"]] | ||
exporter.add_sheet("EXPORT", data) | ||
exporter.export() | ||
assert(os.path.exists("TESTXLSX.xlsx")) |