Skip to content
Permalink
Browse files

documentation + expose more functions to __init__.py

  • Loading branch information...
sdpython committed Jan 3, 2015
1 parent 6f69bb5 commit 607a29fc10c7c316f7512e4b074e99435240f566
@@ -230,3 +230,5 @@ version.txt
*/sphinxdoc/source/*.png
*/sphinxdoc/source/coverage/*
README
*/notebooks/request.html.gz
*/notebooks/urllib.request.html
@@ -0,0 +1,110 @@
{
"metadata": {
"name": "",
"signature": "sha256:fa430d7c64a9a3ed09d29090121e405961bb393758aac4c477521d64fb480bc2"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 1,
"metadata": {},
"source": [
"Helpers about files"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from pyquickhelper import download, gzip_files"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"download(\"https://docs.python.org/3.4/library/urllib.request.html\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 2,
"text": [
"'.\\\\urllib.request.html'"
]
}
],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"gzip_files(\"request.html.gz\", [\"urllib.request.html\"])"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"1"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"os.listdir(\".\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"['example_about_files.ipynb',\n",
" 'example_completion.ipynb',\n",
" 'example_documentation.ipynb',\n",
" 'example_pyquickhelper.ipynb',\n",
" 'exemple_of_fix_menu.ipynb',\n",
" 'having_a_form_in_a_notebook.ipynb',\n",
" 'nbimage.png',\n",
" 'request.html.gz',\n",
" 'urllib.request.html']"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
@@ -1,7 +1,7 @@
{
"metadata": {
"name": "",
"signature": "sha256:5b72e6dbf0f2d46cb3e5b2234cf42f97229bf23ed0f9ea889c5adfd65841af79"
"signature": "sha256:3c702653cd7552f3b2aaa136ff09d991c81b00ff200226c96b6c4b88c022cb21"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -23,6 +23,7 @@
"\n",
"* [Log, run_cmd](#log)\n",
"* [Ask something to the user](#user)\n",
"* [Ask something to the user in a notebook](#usernb)\n",
"* [Explore a folder](#exp)\n",
"\n",
"<h3 id=\"log\">Log, run_cmd</h3>\n",
@@ -150,6 +151,77 @@
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h3 id=\"usernb\">Ask something to the user in a notebook</h3>"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"from pyquickhelper import open_html_form\n",
"params= {\"module\":\"\", \"version\":\"v...\"}\n",
"open_html_form(params, \"fill the fields\", \"form1\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"html": [
"<div style=\"background-color:gainsboro; padding:2px; border:0px;\"><b>fill the fields</b>\n",
"<br />module <input type=\"text\" id=\"form1module\" value=\"\" size=\"80\" />\n",
"<br />version <input type=\"text\" id=\"form1version\" value=\"v...\" size=\"80\" />\n",
"<br /><button onclick=\"set_valueform1()\">Ok</button></div>\n",
"<script type=\"text/Javascript\">\n",
"function form1callback(msg) {\n",
" var ret = msg.content.data['text/plain'];\n",
" $('#outform1').text(ret);\n",
"}\n",
"function set_valueform1(){\n",
" command='form1 = {' ;\n",
" var form1modulevar_value = document.getElementById('form1module').value;\n",
" command += '\"module\":\"' + form1modulevar_value + '\",';\n",
" var form1versionvar_value = document.getElementById('form1version').value;\n",
" command += '\"version\":\"' + form1versionvar_value + '\",';\n",
" command += '}';\n",
" var kernel = IPython.notebook.kernel;\n",
" kernel.execute(command);\n",
"}\n",
"</script>"
],
"metadata": {},
"output_type": "pyout",
"prompt_number": 1,
"text": [
"<IPython.core.display.HTML at 0x7816fb0>"
]
}
],
"prompt_number": 1
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"form1"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"{'version': 'modified', 'module': 'anything'}"
]
}
],
"prompt_number": 5
},
{
"cell_type": "markdown",
"metadata": {},
@@ -14,7 +14,7 @@
if path not in sys.path : sys.path.append (path)
import src

from src.pyquickhelper import download, get_temp_folder, fLOG
from src.pyquickhelper import download, get_temp_folder, fLOG, gzip_files, zip_files


class TestDownload (unittest.TestCase):
@@ -28,6 +28,16 @@ def test_download(self) :
assert os.path.exists(f)
assert f.endswith("ftplib.html")

out = os.path.join(fold, "try.html.gz")
r = gzip_files(out, [f], fLOG = fLOG)
fLOG(r)
assert os.path.exists(out)

out = os.path.join(fold, "try.zip")
r = zip_files(out, [f], fLOG = fLOG)
fLOG(r)
assert os.path.exists(out)


if __name__ == "__main__" :
unittest.main ()
@@ -47,5 +47,6 @@ def check():
from .ipythonhelper.magic_parser import MagicCommandParser
from .helpgen.utils_sphinx_config import NbImage
from .loghelper.repositories.gitlab_helper import GitLabAPI, GitLabException
from .unittests.utils_tests import get_temp_folder, main_wrapper_tests
from .filehelper.internet_helper import download
from .unittests.utils_tests import get_temp_folder, main_wrapper_tests
from .filehelper.compression_helper import zip_files, gzip_files

0 comments on commit 607a29f

Please sign in to comment.
You can’t perform that action at this time.