Skip to content

Commit

Permalink
revert python3 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
shimizukawa committed Apr 9, 2011
1 parent c7f6181 commit e3e4299
Show file tree
Hide file tree
Showing 44 changed files with 4,841 additions and 4,846 deletions.
1 change: 0 additions & 1 deletion .bzrignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
build
__pycache__/
123 changes: 60 additions & 63 deletions doc/ChangeLog

Large diffs are not rendered by default.

160 changes: 80 additions & 80 deletions doc/do_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
#!/usr/bin/env python
"""Script to build documentation using Sphinx.
"""

import fileinput, os, sys

def oscmd(c):
os.system(c)

if os.path.isdir("build"):
os.removedirs("build")

os.makedirs("build/html")
os.makedirs("build/latex")

# html manual.
oscmd('sphinx-build -d build/doctrees source build/html')

if sys.platform != 'win32':
# LaTeX format.
oscmd('sphinx-build -b latex -d build/doctrees source build/latex')

# Produce pdf.
topdir = os.getcwd()
os.chdir('build/latex')

# Change chapter style to section style: allows chapters to start on
# the current page. Works much better for the short chapters we have.
# This must go in the class file rather than the preamble, so we modify
# manual.cls at runtime.
chapter_cmds=r'''
% Local changes.
\renewcommand\chapter{
\thispagestyle{plain}
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter
}
\def\@makechapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries \thechapter \quad #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
\def\@makeschapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
'''

unmodified=True
for line in fileinput.FileInput('manual.cls',inplace=1):
if 'Support for module synopsis' in line and unmodified:
line=chapter_cmds+line
elif 'makechapterhead' in line:
# Already have altered manual.cls: don't need to again.
unmodified=False
print(line, end=' ')

# Copying the makefile produced by sphinx...
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('makeindex -s python.ist pyreadline.idx')
oscmd('makeindex -s python.ist modpyreadline.idx')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')

# Create a manual/ directory with final html/pdf output
# os.chdir(topdir)
# oscmd('rm -rf manual')
# oscmd('mkdir manual')
# oscmd('cp -r build/html/*.html build/html/_static manual/')
# oscmd('cp build/latex/ipython.pdf manual/')
#!/usr/bin/env python
"""Script to build documentation using Sphinx.
"""

import fileinput, os, sys

def oscmd(c):
os.system(c)

if os.path.isdir("build"):
os.removedirs("build")

os.makedirs("build/html")
os.makedirs("build/latex")

# html manual.
oscmd('sphinx-build -d build/doctrees source build/html')

if sys.platform != 'win32':
# LaTeX format.
oscmd('sphinx-build -b latex -d build/doctrees source build/latex')

# Produce pdf.
topdir = os.getcwd()
os.chdir('build/latex')

# Change chapter style to section style: allows chapters to start on
# the current page. Works much better for the short chapters we have.
# This must go in the class file rather than the preamble, so we modify
# manual.cls at runtime.
chapter_cmds=r'''
% Local changes.
\renewcommand\chapter{
\thispagestyle{plain}
\global\@topnum\z@
\@afterindentfalse
\secdef\@chapter\@schapter
}
\def\@makechapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries \thechapter \quad #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
\def\@makeschapterhead#1{
\vspace*{10\p@}
{\raggedright \reset@font \Huge \bfseries #1}
\par\nobreak
\hrulefill
\par\nobreak
\vspace*{10\p@}
}
'''

unmodified=True
for line in fileinput.FileInput('manual.cls',inplace=1):
if 'Support for module synopsis' in line and unmodified:
line=chapter_cmds+line
elif 'makechapterhead' in line:
# Already have altered manual.cls: don't need to again.
unmodified=False
print line,

# Copying the makefile produced by sphinx...
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')
oscmd('makeindex -s python.ist pyreadline.idx')
oscmd('makeindex -s python.ist modpyreadline.idx')
oscmd('pdflatex pyreadline.tex')
oscmd('pdflatex pyreadline.tex')

# Create a manual/ directory with final html/pdf output
# os.chdir(topdir)
# oscmd('rm -rf manual')
# oscmd('mkdir manual')
# oscmd('cp -r build/html/*.html build/html/_static manual/')
# oscmd('cp build/latex/ipython.pdf manual/')
2 changes: 1 addition & 1 deletion doc/source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ like python library can also be useful when implementing commandline like
interfaces in GUIs. The use of pyreadline for anything but the windows
console is still under development.

The pyreadline version 2.x module support only Python 3.x.
The pyreadline module does not yet support Python 3.x this will be targeted for the 2.0 version.


Dependencies
Expand Down
2 changes: 1 addition & 1 deletion eggsetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#*****************************************************************************
import glob
from setuptools import setup,find_packages
exec(compile(open('pyreadline/release.py').read(), 'pyreadline/release.py', 'exec'))
execfile('pyreadline/release.py')

setup(name=name,
version = version,
Expand Down
6 changes: 3 additions & 3 deletions pyreadline/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#*****************************************************************************
from . import unicode_helper, logger, clipboard, lineeditor, modes, console
from .rlmain import *
from . import rlmain
import unicode_helper, logger, clipboard, lineeditor, modes, console
from rlmain import *
import rlmain
32 changes: 16 additions & 16 deletions pyreadline/clipboard/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import sys
success = True
in_ironpython = "IronPython" in sys.version
in_ironpython = u"IronPython" in sys.version
if in_ironpython:
try:
from .ironpython_clipboard import GetClipboardText, SetClipboardText
from ironpython_clipboard import GetClipboardText, SetClipboardText
except ImportError:
from .no_clipboard import GetClipboardText, SetClipboardText
from no_clipboard import GetClipboardText, SetClipboardText

else:
try:
from .win32_clipboard import GetClipboardText, SetClipboardText
from win32_clipboard import GetClipboardText, SetClipboardText
except ImportError:
from .no_clipboard import GetClipboardText, SetClipboardText
from no_clipboard import GetClipboardText, SetClipboardText


def send_data(lists):
Expand All @@ -22,15 +22,15 @@ def set_clipboard_text(toclipboard):
SetClipboardText(str(toclipboard))

def make_tab(lists):
if hasattr(lists, "tolist"):
if hasattr(lists, u"tolist"):
lists = lists.tolist()
ut = []
for rad in lists:
if type(rad) in [list, tuple]:
ut.append("\t".join(["%s"%x for x in rad]))
ut.append(u"\t".join([u"%s"%x for x in rad]))
else:
ut.append("%s"%rad)
return "\n".join(ut)
ut.append(u"%s"%rad)
return u"\n".join(ut)

def make_list_of_list(txt):
def make_num(x):
Expand All @@ -47,26 +47,26 @@ def make_num(x):
return x
ut = []
flag = False
for rad in [x for x in txt.split("\r\n") if x != ""]:
raden=[make_num(x) for x in rad.split("\t")]
if str in list(map(type,raden)):
for rad in [x for x in txt.split(u"\r\n") if x != u""]:
raden=[make_num(x) for x in rad.split(u"\t")]
if str in map(type,raden):
flag = True
ut.append(raden)
return ut, flag


def get_clipboard_text_and_convert(paste_list=False):
"""Get txt from clipboard. if paste_list==True the convert tab separated
u"""Get txt from clipboard. if paste_list==True the convert tab separated
data to list of lists. Enclose list of list in array() if all elements are
numeric"""
txt = GetClipboardText()
if txt:
if paste_list and "\t" in txt:
if paste_list and u"\t" in txt:
array, flag = make_list_of_list(txt)
if flag:
txt = repr(array)
else:
txt = "array(%s)"%repr(array)
txt = "".join([c for c in txt if c not in " \t\r\n"])
txt = u"array(%s)"%repr(array)
txt = u"".join([c for c in txt if c not in u" \t\r\n"])
return txt

6 changes: 3 additions & 3 deletions pyreadline/clipboard/ironpython_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# the file COPYING, distributed as part of this software.
#*****************************************************************************
import clr
clr.AddReferenceByPartialName("System.Windows.Forms")
clr.AddReferenceByPartialName(u"System.Windows.Forms")
import System.Windows.Forms.Clipboard as cb

def GetClipboardText():
Expand All @@ -19,9 +19,9 @@ def GetClipboardText():
def SetClipboardText(text):
cb.SetText(text)

if __name__ == '__main__':
if __name__ == u'__main__':
txt = GetClipboardText() # display last text clipped
print(txt)
print txt



Expand Down
2 changes: 1 addition & 1 deletion pyreadline/clipboard/no_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#*****************************************************************************


mybuffer = ""
mybuffer = u""

def GetClipboardText():
return mybuffer
Expand Down
12 changes: 6 additions & 6 deletions pyreadline/clipboard/win32_clipboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

from ctypes import *
from pyreadline.keysyms.winconstants import CF_TEXT, GHND
from pyreadline.unicode_helper import ensure_str,ensure_bytes
from pyreadline.unicode_helper import ensure_unicode,ensure_str

OpenClipboard = windll.user32.OpenClipboard
OpenClipboard.argtypes = [c_int]
Expand Down Expand Up @@ -80,18 +80,18 @@ def getformatname(format):
return buffer.value

def GetClipboardText():
text = ""
text = u""
if OpenClipboard(0):
hClipMem = GetClipboardData(CF_TEXT)
if hClipMem:
GlobalLock.restype = c_char_p
text = GlobalLock(hClipMem)
GlobalUnlock(hClipMem)
CloseClipboard()
return ensure_str(text)
return ensure_unicode(text)

def SetClipboardText(text):
buffer = c_buffer(ensure_bytes(text))
buffer = c_buffer(ensure_str(text))
bufferSize = sizeof(buffer)
hGlobalMem = GlobalAlloc(c_int(GHND), c_int(bufferSize))
GlobalLock.restype = c_void_p
Expand All @@ -103,6 +103,6 @@ def SetClipboardText(text):
SetClipboardData(c_int(CF_TEXT), c_int(hGlobalMem))
CloseClipboard()

if __name__ == '__main__':
if __name__ == u'__main__':
txt = GetClipboardText() # display last text clipped
print(txt)
print txt
2 changes: 1 addition & 1 deletion pyreadline/configuration/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#if you need to change this uncomment the following line
#pyreadline.unicode_helper.pyreadline_codepage="utf8"
except ImportError:
print("Module readline not available.")
print "Module readline not available."
else:
#import tab completion functionality
import rlcompleter
Expand Down
4 changes: 2 additions & 2 deletions pyreadline/console/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@

if in_ironpython:
try:
from .ironpython_console import *
from ironpython_console import *
success = True
except ImportError:
raise
else:
try:
from .console import *
from console import *
success = True
except ImportError:
pass
Expand Down
Loading

0 comments on commit e3e4299

Please sign in to comment.