]> git.phdru.name Git - sqlconvert.git/commitdiff
Use Portable Python Utilities
authorOleg Broytman <phd@phdru.name>
Sun, 30 Apr 2017 19:49:42 +0000 (22:49 +0300)
committerOleg Broytman <phd@phdru.name>
Sun, 30 Apr 2017 19:52:14 +0000 (22:52 +0300)
devscripts/cmp.py [deleted file]
devscripts/rm.py [deleted file]
docs/news.rst
requirements.txt
setup.py
tox.ini

diff --git a/devscripts/cmp.py b/devscripts/cmp.py
deleted file mode 100755 (executable)
index 0168bec..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#! /usr/bin/env python
-"""cmp.py: compare two files. Portable replacement for cmp."""
-
-import os
-import sys
-
-if sys.argv[1] in ("-h", "--help"):
-    print("Broytman cmp.py 1.0, Copyright (C) 2003-2017 PhiloSoft Design")
-    print("Usage: cmp.py [-h|--help|-V|--version] [-i] file1 file2")
-    sys.exit()
-elif sys.argv[1] in ("-V", "--version"):
-    print("Broytman cmp.py 1.0, Copyright (C) 2003-2017 PhiloSoft Design")
-    sys.exit()
-elif sys.argv[1] == "-i":
-    show_pbar = False
-    fname1 = sys.argv[2]
-    fname2 = sys.argv[3]
-else:
-    show_pbar = sys.stderr.isatty()
-    fname1 = sys.argv[1]
-    fname2 = sys.argv[2]
-
-if show_pbar:
-    try:
-        from m_lib.pbar.tty_pbar import ttyProgressBar
-    except ImportError:
-        show_pbar = 0
-
-if show_pbar:
-    try:
-        size = os.path.getsize(fname1)
-    except:
-        print(fname1, ": no such file")
-        sys.exit(1)
-
-if show_pbar:
-    pbar = ttyProgressBar(0, size)
-
-file1 = open(fname1, 'rb')
-file2 = open(fname2, 'rb')
-
-M = 1024*1024
-diff = False
-count = 0
-
-
-def report():
-    if show_pbar:
-        global pbar
-        del pbar
-    sys.stderr.write("Files differ at %d megabayte block\n" % count)
-    global diff
-    diff = True
-
-
-while True:
-    block1 = file1.read(M)
-    block2 = file2.read(M)
-
-    if show_pbar:
-        pbar.display(file1.tell())
-
-    if block1 and block2:
-        if len(block1) != len(block2):
-            report()
-            break
-    elif block1:
-        report()
-        break
-    elif block2:
-        report()
-        break
-    else:
-        break
-
-    if block1 != block2:
-        report()
-        break
-
-    count += 1
-
-if show_pbar and not diff:
-    del pbar
-
-file1.close()
-file2.close()
-
-if diff:
-    sys.exit(1)
diff --git a/devscripts/rm.py b/devscripts/rm.py
deleted file mode 100755 (executable)
index 4278fef..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#! /usr/bin/env python
-
-import os
-import sys
-
-for filename in sys.argv[1:]:
-    os.unlink(filename)
index bfd3c77a1bc86ddb169e88e45124d97c42ec87d2..52e8ca1bb66e221b84788781f421f2daad49bd8d 100644 (file)
@@ -8,6 +8,8 @@ Version 0.2.0 (2017-05-??)
 
 * Test at Travis and AppVeyor.
 
+* Use Portable Python Utilities.
+
 Version 0.1.2 (2017-04-27)
 --------------------------
 
index af29963fc26f1a8beed8cb1ff81f1fe0a14857e1..e558e85cb6b8393428d10f7061b071811d8f2377 100644 (file)
@@ -6,3 +6,4 @@ SQLObject>=2.2.1; python_version >= '2.6' and python_version < '3.0'
 SQLObject>=3.0.0; python_version >= '3.4'
 m_lib.defenc>=1.0
 m_lib>=3.1
+ppu
index b7de6e4c66e3cfc00699d20453d521034a8b9f8f..a47b42ab7568adae5fa7608116ef7ca66c057707 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -18,7 +18,9 @@ from sqlconvert_version import __version__  # noqa
 kw = {}
 if is_setuptools:
     kw['install_requires'] = [
-        'sqlparse', 'SQLObject>=2.2.1', 'm_lib.defenc>=1.0', 'm_lib>=3.1',
+        'sqlparse', 'SQLObject>=2.2.1',
+        'm_lib.defenc>=1.0', 'm_lib>=3.1',
+        'ppu'
     ]
 
 setup(name='sqlconvert',
diff --git a/tox.ini b/tox.ini
index eb6b3550ced5083e3ed9375c3f1ef48580e61ae4..abc744d7ec549428d227b9077d301f919314a7be 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -13,14 +13,15 @@ commands =
     {envpython} --version
     {envpython} -c "import struct; print(struct.calcsize('P') * 8)"
 deps =
-    sqlparse
     pytest
     pytest-cov
     py26: argparse
+    sqlparse
     py2{6,7}: SQLObject>=2.2.1
     py3{4,5,6}: SQLObject>=3.0.0
     m_lib>=3.1
     m_lib.defenc>=1.0
+    ppu
     postgres: psycopg2
 sitepackages = True
 # Don't fail or warn on uninstalled commands
@@ -34,8 +35,8 @@ commands =
     {[testenv]commands}
     {envpython} -m pytest --cov=sqlconvert
     {envpython} {envbindir}/mysql2sql -P demo/demo.sql test.out
-    {envpython} devscripts/cmp.py -i tests/mysql2sql/test.out test.out
-    {envpython} devscripts/rm.py test.out
+    {envpython} {envbindir}/cmp.py -i tests/mysql2sql/test.out test.out
+    {envpython} {envbindir}/rm.py test.out
 
 [testenv:py26]
 commands = {[general]commands}
@@ -81,7 +82,7 @@ commands = {[postgresql]commands}
 commands =
     {[testenv]commands}
     {envpython} -m pytest --cov=sqlconvert -D sqlite:///tmp/test.sqdb
-    {envpython} devscripts/rm.py /tmp/test.sqdb
+    {envpython} {envbindir}/rm.py /tmp/test.sqdb
 
 [testenv:py26-sqlite]
 commands = {[sqlite]commands}