diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-11-22 10:51:53 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-11-22 10:51:53 +0100 |
commit | 31489088c31b75c5c73dc0d9bab6c63a056c2a4b (patch) | |
tree | 9b1b2eb4d0d47d125b52acedcc1da554cc5afbcd | |
parent | 3faecb776dd8c22d06b04334bb641f901dc70c52 (diff) | |
download | logilab-common-31489088c31b75c5c73dc0d9bab6c63a056c2a4b.tar.gz |
cleanup: remove deprecated modules
-rw-r--r-- | adbh.py | 35 | ||||
-rw-r--r-- | db.py | 49 | ||||
-rw-r--r-- | html.py | 140 | ||||
-rw-r--r-- | sqlgen.py | 31 | ||||
-rw-r--r-- | test/unittest_html.py | 76 |
5 files changed, 0 insertions, 331 deletions
diff --git a/adbh.py b/adbh.py deleted file mode 100644 index a82eb0a..0000000 --- a/adbh.py +++ /dev/null @@ -1,35 +0,0 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of logilab-common. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# logilab-common is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with logilab-common. If not, see <http://www.gnu.org/licenses/>. -"""Helpers for DBMS specific (advanced or non standard) functionalities. -""" -__docformat__ = "restructuredtext en" - -from warnings import warn -warn('this module is deprecated, use logilab.database instead', - DeprecationWarning, stacklevel=1) - -from logilab.database import (FunctionDescr, get_db_helper as get_adv_func_helper, - _GenericAdvFuncHelper, - _ADV_FUNC_HELPER_DIRECTORY as ADV_FUNC_HELPER_DIRECTORY) -from logilab.common.decorators import monkeypatch - -@monkeypatch(_GenericAdvFuncHelper, 'func_sqlname') -@classmethod -def func_sqlname(cls, funcname): - funcdef = cls.function_description(funcname) - return funcdef.name_mapping.get(cls.backend_name, funcname) @@ -1,49 +0,0 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of logilab-common. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# logilab-common is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with logilab-common. If not, see <http://www.gnu.org/licenses/>. -"""Wrappers to get actually replaceable DBAPI2 compliant modules and -database connection whatever the database and client lib used. - -Currently support: - -- postgresql (pgdb, psycopg, psycopg2, pyPgSQL) -- mysql (MySQLdb) -- sqlite (pysqlite2, sqlite, sqlite3) - -just use the `get_connection` function from this module to get a -wrapped connection. If multiple drivers for a database are available, -you can control which one you want to use using the -`set_prefered_driver` function. - -Additional helpers are also provided for advanced functionalities such -as listing existing users or databases, creating database... Get the -helper for your database using the `get_adv_func_helper` function. -""" -__docformat__ = "restructuredtext en" - -from warnings import warn -warn('this module is deprecated, use logilab.database instead', - DeprecationWarning, stacklevel=1) - -from logilab.database import (get_connection, set_prefered_driver, - get_dbapi_compliant_module as _gdcm, - get_db_helper as _gdh) - -def get_dbapi_compliant_module(driver, *args, **kwargs): - module = _gdcm(driver, *args, **kwargs) - module.adv_func_helper = _gdh(driver) - return module diff --git a/html.py b/html.py deleted file mode 100644 index 0cfc81a..0000000 --- a/html.py +++ /dev/null @@ -1,140 +0,0 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of logilab-common. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# logilab-common is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with logilab-common. If not, see <http://www.gnu.org/licenses/>. -"""render a tree in HTML.""" -__docformat__ = "restructuredtext en" - -from warnings import warn -warn('lgc.html module is deprecated', DeprecationWarning, stacklevel=2) - - -def render_HTML_tree(tree, selected_node=None, render_node=None, caption=None): - """ - Generate a pure HTML representation of a tree given as an instance - of a logilab.common.tree.Node - - selected_node is the currently selected node (if any) which will - have its surrounding <div> have id="selected" (which default - to a bold border libe with the default CSS). - - render_node is a function that should take a Node content (Node.id) - as parameter and should return a string (what will be displayed - in the cell). - - Warning: proper rendering of the generated html code depends on html_tree.css - """ - tree_depth = tree.depth_down() - if render_node is None: - render_node = str - - # helper function that build a matrix from the tree, like: - # +------+-----------+-----------+ - # | root | child_1_1 | child_2_1 | - # | root | child_1_1 | child_2_2 | - # | root | child_1_2 | | - # | root | child_1_3 | child_2_3 | - # | root | child_1_3 | child_2_4 | - # +------+-----------+-----------+ - # from: - # root -+- child_1_1 -+- child_2_1 - # | | - # | +- child_2_2 - # +- child_1_2 - # | - # +- child1_3 -+- child_2_3 - # | - # +- child_2_2 - def build_matrix(path, matrix): - if path[-1].is_leaf(): - matrix.append(path[:]) - else: - for child in path[-1].children: - build_matrix(path[:] + [child], matrix) - - matrix = [] - build_matrix([tree], matrix) - - # make all lines in the matrix have the same number of columns - for line in matrix: - line.extend([None]*(tree_depth-len(line))) - for i in range(len(matrix)-1, 0, -1): - prev_line, line = matrix[i-1:i+1] - for j in range(len(line)): - if line[j] == prev_line[j]: - line[j] = None - - # We build the matrix of link types (between 2 cells on a line of the matrix) - # link types are : - link_types = {(True, True, True ): 1, # T - (False, False, True ): 2, # | - (False, True, True ): 3, # + (actually, vert. bar with horiz. bar on the right) - (False, True, False): 4, # L - (True, True, False): 5, # - - } - links = [] - for i, line in enumerate(matrix): - links.append([]) - for j in range(tree_depth-1): - cell_11 = line[j] is not None - cell_12 = line[j+1] is not None - cell_21 = line[j+1] is not None and line[j+1].next_sibling() is not None - link_type = link_types.get((cell_11, cell_12, cell_21), 0) - if link_type == 0 and i > 0 and links[i-1][j] in (1, 2, 3): - link_type = 2 - links[-1].append(link_type) - - - # We can now generate the HTML code for the <table> - s = u'<table class="tree">\n' - if caption: - s += '<caption>%s</caption>\n' % caption - - for i, link_line in enumerate(links): - line = matrix[i] - - s += '<tr>' - for j, link_cell in enumerate(link_line): - cell = line[j] - if cell: - if cell.id == selected_node: - s += '<td class="tree_cell" rowspan="2"><div class="selected tree_cell">%s</div></td>' % (render_node(cell.id)) - else: - s += '<td class="tree_cell" rowspan="2"><div class="tree_cell">%s</div></td>' % (render_node(cell.id)) - else: - s += '<td rowspan="2"> </td>' - s += '<td class="tree_cell_%d_1"> </td>' % link_cell - s += '<td class="tree_cell_%d_2"> </td>' % link_cell - - cell = line[-1] - if cell: - if cell.id == selected_node: - s += '<td class="tree_cell" rowspan="2"><div class="selected tree_cell">%s</div></td>' % (render_node(cell.id)) - else: - s += '<td class="tree_cell" rowspan="2"><div class="tree_cell">%s</div></td>' % (render_node(cell.id)) - else: - s += '<td rowspan="2"> </td>' - - s += '</tr>\n' - if link_line: - s += '<tr>' - for j, link_cell in enumerate(link_line): - s += '<td class="tree_cell_%d_3"> </td>' % link_cell - s += '<td class="tree_cell_%d_4"> </td>' % link_cell - s += '</tr>\n' - - s += '</table>' - return s diff --git a/sqlgen.py b/sqlgen.py deleted file mode 100644 index 8d4a1c1..0000000 --- a/sqlgen.py +++ /dev/null @@ -1,31 +0,0 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of logilab-common. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# logilab-common is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with logilab-common. If not, see <http://www.gnu.org/licenses/>. -"""Help to generate SQL strings usable by the Python DB-API. - - - - - -""" -__docformat__ = "restructuredtext en" - - -from warnings import warn -warn('this module is deprecated, use logilab.database instead', - DeprecationWarning, stacklevel=1) -from logilab.database.sqlgen import * diff --git a/test/unittest_html.py b/test/unittest_html.py deleted file mode 100644 index a055517..0000000 --- a/test/unittest_html.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. -# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr -# -# This file is part of logilab-common. -# -# logilab-common is free software: you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the Free -# Software Foundation, either version 2.1 of the License, or (at your option) any -# later version. -# -# logilab-common is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more -# details. -# -# You should have received a copy of the GNU Lesser General Public License along -# with logilab-common. If not, see <http://www.gnu.org/licenses/>. -"""unittests for logilab.common.html - -:organization: Logilab - - - -""" - -__docformat__ = "restructuredtext en" - -from logilab.common.testlib import TestCase, unittest_main -from logilab.common.tree import Node - -from logilab.common import html - -tree = ('root', ( - ('child_1_1', ( - ('child_2_1', ()), ('child_2_2', ( - ('child_3_1', ()), - ('child_3_2', ()), - ('child_3_3', ()), - )))), - ('child_1_2', (('child_2_3', ()),)))) - -generated_html = """\ -<table class="tree"> -<tr><td class="tree_cell" rowspan="2"><div class="tree_cell">root</div></td><td class="tree_cell_1_1"> </td><td class="tree_cell_1_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_1_1</div></td><td class="tree_cell_1_1"> </td><td class="tree_cell_1_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_2_1</div></td><td class="tree_cell_0_1"> </td><td class="tree_cell_0_2"> </td><td rowspan="2"> </td></tr> -<tr><td class="tree_cell_1_3"> </td><td class="tree_cell_1_4"> </td><td class="tree_cell_1_3"> </td><td class="tree_cell_1_4"> </td><td class="tree_cell_0_3"> </td><td class="tree_cell_0_4"> </td></tr> -<tr><td rowspan="2"> </td><td class="tree_cell_2_1"> </td><td class="tree_cell_2_2"> </td><td rowspan="2"> </td><td class="tree_cell_4_1"> </td><td class="tree_cell_4_2"> </td><td class="tree_cell" rowspan="2"><div class="selected tree_cell">child_2_2</div></td><td class="tree_cell_1_1"> </td><td class="tree_cell_1_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_3_1</div></td></tr> -<tr><td class="tree_cell_2_3"> </td><td class="tree_cell_2_4"> </td><td class="tree_cell_4_3"> </td><td class="tree_cell_4_4"> </td><td class="tree_cell_1_3"> </td><td class="tree_cell_1_4"> </td></tr> -<tr><td rowspan="2"> </td><td class="tree_cell_2_1"> </td><td class="tree_cell_2_2"> </td><td rowspan="2"> </td><td class="tree_cell_0_1"> </td><td class="tree_cell_0_2"> </td><td rowspan="2"> </td><td class="tree_cell_3_1"> </td><td class="tree_cell_3_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_3_2</div></td></tr> -<tr><td class="tree_cell_2_3"> </td><td class="tree_cell_2_4"> </td><td class="tree_cell_0_3"> </td><td class="tree_cell_0_4"> </td><td class="tree_cell_3_3"> </td><td class="tree_cell_3_4"> </td></tr> -<tr><td rowspan="2"> </td><td class="tree_cell_2_1"> </td><td class="tree_cell_2_2"> </td><td rowspan="2"> </td><td class="tree_cell_0_1"> </td><td class="tree_cell_0_2"> </td><td rowspan="2"> </td><td class="tree_cell_4_1"> </td><td class="tree_cell_4_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_3_3</div></td></tr> -<tr><td class="tree_cell_2_3"> </td><td class="tree_cell_2_4"> </td><td class="tree_cell_0_3"> </td><td class="tree_cell_0_4"> </td><td class="tree_cell_4_3"> </td><td class="tree_cell_4_4"> </td></tr> -<tr><td rowspan="2"> </td><td class="tree_cell_4_1"> </td><td class="tree_cell_4_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_1_2</div></td><td class="tree_cell_5_1"> </td><td class="tree_cell_5_2"> </td><td class="tree_cell" rowspan="2"><div class="tree_cell">child_2_3</div></td><td class="tree_cell_0_1"> </td><td class="tree_cell_0_2"> </td><td rowspan="2"> </td></tr> -<tr><td class="tree_cell_4_3"> </td><td class="tree_cell_4_4"> </td><td class="tree_cell_5_3"> </td><td class="tree_cell_5_4"> </td><td class="tree_cell_0_3"> </td><td class="tree_cell_0_4"> </td></tr> -</table>\ -""" - -def make_tree(tupletree): - n = Node(tupletree[0]) - for child in tupletree[1]: - n.append(make_tree(child)) - return n - -class UIlibHTMLGenerationTC(TestCase): - """ a basic tree node, caracterised by an id""" - def setUp(self): - """ called before each test from this class """ - self.o = make_tree(tree) - - def test_generated_html(self): - s = html.render_HTML_tree(self.o, selected_node="child_2_2") - self.assertMultiLineEqual(s, generated_html) - - -if __name__ == '__main__': - unittest_main() |