Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
474 changes: 234 additions & 240 deletions HISTORY.rst

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions _unittests/ut_helpgen/test_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_format_history_release(self):
**Bugfix**

* `46`: update to Sphinx 1.6
* `54`: fix searchbox for `sphinx_rtd_theme <https://github.com/rtfd/sphinx_rtd_theme>`_
* #54: fix searchbox for `sphinx_rtd_theme <https://github.com/rtfd/sphinx_rtd_theme>`_

**Features**

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_format_history_release(self):
* :release:`1.4.2 <2016-09-18>`
""".replace(" ", "")

self.assertEqual(content.strip(" \r\n\t"), expect.strip(" \r\n\t"))
self.assertEqual(expect.strip(" \r\n\t"), content.strip(" \r\n\t"))

def test_format_history_basic(self):
fLOG(
Expand Down Expand Up @@ -175,4 +175,5 @@ def test_format_history_long(self):


if __name__ == "__main__":
TestPaths().test_format_history_release()
unittest.main()
2 changes: 1 addition & 1 deletion _unittests/ut_loghelper/test_history_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_history_existing(self):
self.assertGreater(nb, 1)

output = compile_history(history)
self.assertIn('* `139`:', output)
self.assertIn('* #139:', output)
nb = 0
for h in history:
rel = h['release']
Expand Down
10 changes: 10 additions & 0 deletions _unittests/ut_sphinxext/test_template_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@

class TestTemplateExtension(unittest.TestCase):

def test_python_link_doc(self):
link = python_link_doc("os")
self.assertEqual(
link,
"`os <https://docs.python.org/3/library/os.html>`_")
link = python_link_doc("os", "getcwd")
self.assertEqual(
link,
"`os.getcwd <https://docs.python.org/3/library/os.html#os.getcwd>`_")

def test_tpl_inline(self):
fLOG(
__file__,
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/benchhelper/grid_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def bench(self, **params):

appe["_btry"] = metrics["_btry"]
if "_i" in metrics:
del metrics["_i"]
del metrics["_i"] # pragma: no cover
results.append((metrics, appe))

return results
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/cli/cli_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,4 +464,4 @@ def call_gui_function(dfct, fLOG=print, utest=False):
win = main_loop_functions(dfct, title="{0} command line".format(modname),
mainloop=not utest)
return win
return None
return None # pragma: no cover
2 changes: 1 addition & 1 deletion src/pyquickhelper/cli/simplified_fct.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def sphinx_rst(input="", writer="html", keep_warnings=False,
os.path.exists(input)):
content = read_content_ufs(input)
else:
content = input
content = input # pragma: no cover
if directives:
raise NotImplementedError(
"Cannot specify directives yet.") # pragma: no cover
Expand Down
3 changes: 2 additions & 1 deletion src/pyquickhelper/filehelper/download_urls_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ def download_urls_in_folder_content(folder, pattern=".+[.]((py)|(ipynb))", neg_p
if len(fall) == 0:
continue
if fLOG is not None:
fLOG("[download_urls_in_folder_content] explore '{}'".format(obj))
fLOG( # pragma: no cover
"[download_urls_in_folder_content] explore '{}'".format(obj))
urls = [f[0] for f in fall]
r = get_urls_content_timeout(urls, folder=folder_dest, timeout=timeout,
raise_exception=raise_exception, chunk=chunk,
Expand Down
3 changes: 2 additions & 1 deletion src/pyquickhelper/filehelper/file_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def convert_st_date_to_datetime(t):
if isinstance(t, str):
if "." in t:
return datetime.datetime.strptime(t, "%Y-%m-%d %H:%M:%S.%f")
return datetime.datetime.strptime(t, "%Y-%m-%d %H:%M:%S")
return datetime.datetime.strptime( # pragma: no cover
t, "%Y-%m-%d %H:%M:%S")
return datetime.datetime.fromtimestamp(t)


Expand Down
20 changes: 10 additions & 10 deletions src/pyquickhelper/filehelper/ftp_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,28 @@ def run_command(self, command, *args, **kwargs):
"""
if command == self._ftp.mlsd and args == ('.',):
return [('setup.py', {'name': 'setup.py'})]
elif command == self._ftp.cwd and args == ('.',):
if command == self._ftp.cwd and args == ('.',):
return None
elif command == self._ftp.pwd and len(args) == 0:
if command == self._ftp.pwd and len(args) == 0:
return "."
elif command == self._ftp.cwd and args == ('..',):
if command == self._ftp.cwd and args == ('..',):
return None
elif command == self._ftp.storbinary and args[0] == 'STOR test_transfer_ftp.py':
if command == self._ftp.storbinary and args[0] == 'STOR test_transfer_ftp.py':
self._store[args[0]] = args
return None
elif command == self._ftp.retrbinary and args[0] == 'RETR test_transfer_ftp.py':
if command == self._ftp.retrbinary and args[0] == 'RETR test_transfer_ftp.py':
b = self._store[args[0].replace("RETR", "STOR")][1]
return b'ee'
elif command == self._ftp.cwd and args == ('backup',):
if command == self._ftp.cwd and args == ('backup',):
self._store[args[0]] = args
return None
elif command == self._ftp.storbinary and args[0] == 'STOR setup.py':
if command == self._ftp.storbinary and args[0] == 'STOR setup.py':
self._store[args[0]] = args
return None
elif command == self._ftp.retrbinary and args[0] == 'RETR setup.py':
if command == self._ftp.retrbinary and args[0] == 'RETR setup.py':
b = self._store[args[0].replace("RETR", "STOR")][1]
s = b.getbuffer()
args[1](s)
return len(s)
else:
raise Exception("command='{0}'\nargs={1}".format(command, args))
raise RuntimeError( # pragma: no cover
"command='{0}'\nargs={1}".format(command, args))
7 changes: 3 additions & 4 deletions src/pyquickhelper/filehelper/transfer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def transfer(self, path, data):
@param path path to remove location
@return boolean
"""
raise NotImplementedError()
raise NotImplementedError() # pragma: no cover

def retrieve(self, path, exc=True):
"""
Expand All @@ -89,7 +89,7 @@ def retrieve(self, path, exc=True):
@param exc keep exception
@return data
"""
raise NotImplementedError()
raise NotImplementedError() # pragma: no cover

def retrieve_mapping(self, decrypt):
"""
Expand All @@ -101,8 +101,7 @@ def retrieve_mapping(self, decrypt):
m = self.retrieve("__mapping__", exc=False)
if m is None:
return {}
else:
return TransferAPI.bytes2mapping(m)
return TransferAPI.bytes2mapping(m)

def transfer_mapping(self, mapping, encrypt, filename=None):
"""
Expand Down
7 changes: 3 additions & 4 deletions src/pyquickhelper/filehelper/transfer_api_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def retrieve(self, path, exc=True):
if os.path.exists(src):
with open(src, "rb") as f:
return f.read()
elif exc:
raise FileNotFoundError(path)
else:
return None
if exc:
raise FileNotFoundError(path) # pragma: no cover
return None
2 changes: 1 addition & 1 deletion src/pyquickhelper/filehelper/visual_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def create_visual_diff_through_html_files(file1, file2, encoding="utf8", page=No
if page is not None:
with open(page, "w", encoding="utf8") as f:
f.write(diff)
if browser:
if browser: # pragma: no cover
if page is None:
raise AttributeError("browser is True, page must be True")
import webbrowser
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/helpgen/conf_path_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def find_in_PATH(prog):
for p in path.split(sep):
f = os.path.join(p, prog)
if os.path.exists(f):
return p
return p # pragma: no cover
return None


Expand Down Expand Up @@ -143,7 +143,7 @@ def custom_ensuredir(path):
# 0 for Jython/Win32
EEXIST = getattr(errno, 'EEXIST', 0)
if err.errno not in [0, EEXIST]:
raise
raise # pragma: no cover


def find_dvipng_path(exc=True):
Expand Down
5 changes: 3 additions & 2 deletions src/pyquickhelper/helpgen/help_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ def get_help_usage():
"""
Returns the usage ``python setup.py build_sphinx``.
"""
return """
return ( # pragma: no cover
"""
This command will build the documentation form the source.
It will not work from the installed package.
This is a custom build, the regular options with build_sphinx will not work.
Expand All @@ -17,4 +18,4 @@ def get_help_usage():
Usage:

python setup.py build_sphinx
""".replace(" ", "")
""".replace(" ", ""))
7 changes: 4 additions & 3 deletions src/pyquickhelper/helpgen/markdown_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ def clean_line(line):
try:
for (regex, sub) in regex_subs:
line = regex.sub(sub, line)
except Exception as ex:
raise Exception("[sphinxerror]-A %s, (line(%s)" %
(regex, sub)) from ex
except Exception as ex: # pragma: no cover
raise RuntimeError(
"[sphinxerror]-A %s, (line(%s)" % (
regex, sub)) from ex

return line

Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/helpgen/notebook_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def process_raw_html(source, extra_args=None):
:local:
"""
if source is None:
return source
return source # pragma: no cover
if 'var update_menu = function() {' in source:
return "\n\n.. contents::\n :local:\n\n"
return "\n\n.. raw:: html\n\n" + indent(source, prefix=' ')
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/helpgen/pandoc_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def call_pandoc(params, fLOG=noLOG):
cmd = '"{0}" {1}'.format(pandoc, params)
out, err = run_cmd(cmd, wait=True, fLOG=fLOG)
if err is not None and "Cannot decode byte" in err:
raise RuntimeError(
raise RuntimeError( # pragma: no cover
"Issue with pandoc:\n{0}\n"
"--OUT--\n{1}\n--ERR--\n{2}".format(
cmd, out, err))
Expand Down
5 changes: 3 additions & 2 deletions src/pyquickhelper/helpgen/post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def repipy(le):
for k, v in sorted(nblinks.items()))
extension = "You should add this link into the documentation " \
"configuration file in variable 'nblinks'."
raise HelpGenException(
raise HelpGenException( # pragma: no cover
"A reference was not found: '{0}' - '{1}' "
"format={2}, nblinks=\n{3}\n{4}".format(
anc, url, format, mes, extension))
Expand Down Expand Up @@ -360,7 +360,8 @@ def startss(line):
code = "".join(
(_[4:] if _.startswith(" ") else _) for _ in lines[memopos + 1:pos])
if len(code) == 0:
fLOG("[post_process_rst_output] EMPTY-SECTION in ", file)
fLOG( # pragma: no cover
"[post_process_rst_output] EMPTY-SECTION in ", file)
else:
try:
cmp = compile(code, "", "exec")
Expand Down
5 changes: 3 additions & 2 deletions src/pyquickhelper/helpgen/post_process_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ def find_custom_latex_processing(name):
Determines the corresponding post processing function
associated to name.
"""
raise ValueError(
"Unable to find any post processing function associated to '{0}'".format(name))
raise ValueError( # pragma: no cover
"Unable to find any post processing function associated "
"to '{0}'".format(name))
5 changes: 3 additions & 2 deletions src/pyquickhelper/helpgen/process_notebook_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def get_exporter(format, add_writer=False):
exp = LatexExporter
else:
form = "slides, pdf, latex, markdown, html, rst, python, notebook, template"
raise ValueError(
raise ValueError( # pragma: no cover
"unexpected format: {0}, it should be in:\n{1}".format(format, form))

if add_writer:
Expand Down Expand Up @@ -172,7 +172,8 @@ def nb2rst(nb_file, outfile, exc=True, post_process=True):

name, ext = os.path.splitext(outfile)
if ext != '.rst':
raise ValueError("'{0}' should have extension '.rst'".format(outfile))
raise ValueError( # pragma: no cover
"'{0}' should have extension '.rst'".format(outfile))
writer.build_directory = os.path.dirname(outfile)
writer.write(source, meta, notebook_name=name)

Expand Down
21 changes: 18 additions & 3 deletions src/pyquickhelper/helpgen/sphinx_main_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ def format_history(src, dest, format="basic"):

new_lines = []
if format == "release":

tag = None
for i in range(0, len(lines)):
line = lines[i].rstrip("\r\t\n ")
Expand Down Expand Up @@ -482,17 +481,33 @@ def format_history(src, dest, format="basic"):
if new_lines[-1].startswith("==="):
new_lines.append("")
new_lines.append(res)
elif nline.startswith("#"):
if tag is None:
tag = 'issue'
spl = nline.split(':')
nb, doc = spl[0], ':'.join(spl[1:])
res = "* :{0}:`{1}`: {2}".format(tag, nb.strip("#"), doc.strip(' '))
if new_lines[-1].startswith("==="):
new_lines.append("")
new_lines.append(res)
else:
new_lines.append(line)
if line.startswith(".. _"):
new_lines.append("")
elif format == "basic":
reg = re.compile("(.*?)`([0-9]+)`:(.*?)[(]([-0-9]{10})[)]")
reg = re.compile(
"(.*?)((`([0-9]+)`:)|([#]([0-9]+):))(.*?)[(]([-0-9]{10})[)]")
for line in lines:
match = reg.search(line)
if match:
gr = match.groups()
new_line = "{0}:issue:`{1}`:{2}({3})".format(*gr)
issue = gr[3]
if issue is None or len(issue) == 0:
issue = gr[5]
desc = gr[6].strip()
date = gr[7].strip()
new_line = "{0}:issue:`{1}`: {2} ({3})".format(
gr[0], issue, desc, date)
new_lines.append(new_line)
else:
new_lines.append(line.strip("\n\r"))
Expand Down
2 changes: 1 addition & 1 deletion src/pyquickhelper/helpgen/utils_sphinx_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def validate_file_for_help(filename, fexclude=lambda f: False):
@return boolean
"""
if fexclude is not None and fexclude(filename):
return False
return False # pragma: no cover

if filename.endswith(".pyd") or filename.endswith(".so"):
return True
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/ipythonhelper/magic_class_compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def compress(self, line):
return zip_files(dest, files)
if format == "gzip":
return gzip_files(dest, files)
if format == "7z":
if format == "7z": # pragma: no cover
return zip7_files(dest, files)
raise ValueError(
raise ValueError( # pragma: no cover
"Unexpected format: '{0}' from file '{1}'?".format(
format, dest))
return None
Expand Down
4 changes: 2 additions & 2 deletions src/pyquickhelper/ipythonhelper/magic_class_crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def encrypt_file(self, line):

return encrypt_stream(key=password, filename=source, out_filename=dest,
chunksize=os.stat(source).st_size * 2 + 1)
return None
return None # pragma: no cover

@line_magic
def decrypt_file(self, line):
Expand Down Expand Up @@ -128,7 +128,7 @@ def decrypt_file(self, line):

return decrypt_stream(key=password, filename=source, out_filename=dest,
chunksize=os.stat(source).st_size * 2 + 1)
return None
return None # pragma: no cover


def register_file_magics(ip=None): # pragma: no cover
Expand Down
Loading