Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dorie
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
31
Issues
31
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
Operations
Operations
Incidents
Environments
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
dorie
dorie
Commits
5ee60840
Commit
5ee60840
authored
Sep 21, 2016
by
Dion Haefner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed python 2 support
parent
a2363ddd
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
24 additions
and
14 deletions
+24
-14
python/CMakeLists.txt
python/CMakeLists.txt
+1
-1
python/parscraper/dorie/parscraper/match_parameters.py
python/parscraper/dorie/parscraper/match_parameters.py
+2
-0
python/parscraper/dorie/parscraper/readers/xml.py
python/parscraper/dorie/parscraper/readers/xml.py
+2
-0
python/parscraper/dorie/parscraper/wrapper/__init__.py
python/parscraper/dorie/parscraper/wrapper/__init__.py
+0
-0
python/parscraper/dorie/parscraper/wrapper/scrape_folder.py
python/parscraper/dorie/parscraper/wrapper/scrape_folder.py
+4
-0
python/parscraper/dorie/parscraper/writers/html.py
python/parscraper/dorie/parscraper/writers/html.py
+2
-0
python/parscraper/dorie/parscraper/writers/ini.py
python/parscraper/dorie/parscraper/writers/ini.py
+2
-0
python/parscraper/dorie/parscraper/writers/rst.py
python/parscraper/dorie/parscraper/writers/rst.py
+10
-12
python/parscraper/wrapper/scrape_folder.py
python/parscraper/wrapper/scrape_folder.py
+1
-1
No files found.
python/CMakeLists.txt
View file @
5ee60840
function
(
install_python_package curdir packagelist
)
message
(
STATUS
"Installing python package dorie.
${
curdir
}
"
)
dune_install_python_package
(
PATH
${
curdir
}
ADDITIONAL_PIP_PARAMS
"-r
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
curdir
}
/requirements.txt -q"
)
dune_install_python_package
(
PATH
${
curdir
}
ADDITIONAL_PIP_PARAMS
-r
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
curdir
}
/requirements.txt -q
)
set
(
${
packagelist
}
${${
packagelist
}}
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
curdir
}
PARENT_SCOPE
)
endfunction
()
...
...
python/parscraper/dorie/parscraper/match_parameters.py
View file @
5ee60840
from
__future__
import
absolute_import
import
os
from
warnings
import
warn
...
...
python/parscraper/dorie/parscraper/readers/xml.py
View file @
5ee60840
from
__future__
import
absolute_import
import
xml.etree.ElementTree
as
ET
from
warnings
import
warn
from
collections
import
OrderedDict
...
...
python/parscraper/dorie/parscraper/wrapper/__init__.py
0 → 100644
View file @
5ee60840
python/parscraper/dorie/parscraper/wrapper/scrape_folder.py
View file @
5ee60840
...
...
@@ -2,6 +2,7 @@ import os
import
sys
import
warnings
import
argparse
import
traceback
from
dorie.parscraper
import
readers
,
writers
,
match_parameters
from
dorie.parscraper.warnings
import
OutputWarning
...
...
@@ -45,6 +46,9 @@ def scrape(xml_file,source_folder,out,css=None,debug=False):
raise
else
:
warnings
.
warn
(
"Output failed for file {0} with error:
\n
{1}"
.
format
(
o
,
repr
(
e
)),
OutputWarning
)
if
debug
:
exc_type
,
exc_value
,
exc_traceback
=
sys
.
exc_info
()
traceback
.
print_exception
(
exc_type
,
exc_value
,
exc_traceback
)
else
:
warnings
.
warn
(
"Unknown output format: .{}. Skipping output"
.
format
(
file_suffix
),
OutputWarning
)
python/parscraper/dorie/parscraper/writers/html.py
View file @
5ee60840
from
__future__
import
unicode_literals
import
datetime
import
os
import
re
...
...
python/parscraper/dorie/parscraper/writers/ini.py
View file @
5ee60840
from
__future__
import
unicode_literals
import
datetime
import
os
import
re
...
...
python/parscraper/dorie/parscraper/writers/rst.py
View file @
5ee60840
from
__future__
import
unicode_literals
import
datetime
import
os
import
re
try
:
str
=
unicode
except
NameError
:
pass
from
dorie.utilities.check_path
import
check_path
from
dorie.parscraper.parameter
import
Parameter
...
...
@@ -35,10 +42,10 @@ def write(parameters,out,path_base,*args,**kwargs):
check_path
(
out
)
with
open
(
out
,
"w"
)
as
output
:
rst_document
=
_format_rst
(
parameters
,
headings
,
widths
,
table_content
)
output
.
write
(
rst_document
)
output
.
write
(
rst_document
.
encode
(
'utf-8'
)
)
def
_format_rst
(
parameters
,
headers
,
widths
,
content_function
):
rst
=
""
rst
=
u
""
for
category
in
parameters
:
rst
+=
_format_heading
(
category
)
table_content
=
[
content_function
(
p
)
for
p
in
parameters
[
category
]]
...
...
@@ -49,7 +56,7 @@ def _format_table(content,headers,widths):
tab
=
" "
delimiter
=
","
table
=
""
table
=
u
""
table
+=
".. csv-table::
\n
"
table
+=
tab
+
":header: {}
\n
"
.
format
(
", "
.
join
(
headers
))
table
+=
tab
+
":delim: {}
\n
"
.
format
(
delimiter
)
...
...
@@ -72,15 +79,6 @@ def _format_heading(text):
sep
=
"+"
*
len
(
text
)
return
text
+
"
\n
"
+
sep
+
"
\n\n
"
def
_format_footer
():
# UNUSED
tab
=
" "
footer
=
""
footer
+=
".. class:: center"
footer
+=
tab
+
"Automatically created by the :mod:`DORiE parameter scraper <dorie.parscraper>`
\n\n
"
footer
+=
tab
+
"{0:%d-%m-%Y, %H:%M}"
.
format
(
datetime
.
datetime
.
today
())
return
footer
def
_sources
(
p
,
path_base
):
"""
Assembles the cell text for the sources of a parameter. Since the
...
...
python/parscraper/wrapper/scrape_folder.py
View file @
5ee60840
...
...
@@ -9,7 +9,7 @@ Script invoking the parameter scraper on a folder given via command line.
"""
if
__name__
==
"__main__"
:
try
:
# catch all exceptions
we
we can output an error message
try
:
# catch all exceptions
so
we can output an error message
with
warnings
.
catch_warnings
(
record
=
True
)
as
warn
:
# catch all warnings so we can count them
# PARSE COMMAND LINE
parser
=
argparse
.
ArgumentParser
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment