Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.x ready. #19

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
98e430b
Update setup.py
zbarge Dec 4, 2016
907bcd6
Update setup.py
zbarge Dec 4, 2016
af425f0
Compatibility for Python 3.5 at least to install and use CSVImportDia…
zbarge Dec 4, 2016
af27399
Added small a functional example.
Dec 5, 2016
bddab1f
Added some more choices to csv import view.
Dec 5, 2016
3315391
Merge remote-tracking branch 'refs/remotes/origin/patch-1'
Dec 5, 2016
d46ad0c
Revert "Added some more choices to csv import view."
Dec 5, 2016
80afb5c
minor pep8 change
Dec 5, 2016
2131d18
Merge remote-tracking branch 'origin/master'
Dec 5, 2016
e02de77
Rename README to README.md
Dec 5, 2016
d345e0f
Attempting to make test py3 compatible
Dec 5, 2016
0603b38
readme.md fix
Dec 5, 2016
b8ab200
print statement update
Dec 5, 2016
5af560e
Ran 2to3 on pandasqt directory
Dec 5, 2016
c027029
missed one
Dec 5, 2016
1f8a66e
CONVERT IT ALL!!!
Dec 5, 2016
e96718a
Updates to README.md
Dec 5, 2016
50e18dc
Merge pull request #1 from draperjames/patch-1
zbarge Dec 5, 2016
250a6a3
Correction of a few small mistakes
Dec 5, 2016
f7f2e90
Merge pull request #2 from draperjames/master
zbarge Dec 5, 2016
aa3f379
Update README.md
zbarge Dec 5, 2016
b5c3204
DataFrame Model can store the filepath it originated from now.
zbarge Dec 5, 2016
62639f5
CSVDialogs updated
zbarge Dec 5, 2016
f01548f
Dialogs started to manage any type of file
zbarge Dec 5, 2016
b598f26
CSVDialog update
zbarge Dec 5, 2016
22d7b9b
Merge pull request #1 from zbarge/master
Dec 6, 2016
37593b1
Added some checklist items
Dec 6, 2016
7b302e0
Trial travis
Dec 6, 2016
8e5b725
small change
Dec 6, 2016
c2e1178
fixed travis.yml
Dec 6, 2016
cabcbbf
gitter chat link fix
Dec 6, 2016
c876011
Merge pull request #3 from draperjames/master
Dec 6, 2016
241f0ef
adding windows tests to travis
Dec 6, 2016
3014627
Merge pull request #4 from draperjames/master
Dec 6, 2016
49b9f3b
Merge remote-tracking branch 'refs/remotes/zbarge/master'
Dec 6, 2016
8edde1a
Fixed conflict.
Dec 6, 2016
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ docs/_build/
target/

.eric4project
*.e4p
*.e4p
*.bak
46 changes: 46 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
language: python
sudo: false

env:
global:
- MINICONDA_VERSION="latest"
- MINICONDA_LINUX="Linux-x86_64"
- MINICONDA_OSX="MacOSX-x86_64"

matrix:
include:
# Python3
# Windows using pip packages
- python: "3.5"
env: USE_QT_API=PyQt5 USE_CONDA=false
os: windows
- python: "3.5"
env: USE_QT_API=PyQt4 USE_CONDA=false
os: windows
# Linux using pip packages
- python: "3.5"
env: USE_QT_API=PyQt5 USE_CONDA=false
os: linux
- python: "3.5"
env: USE_QT_API=PyQt4 USE_CONDA=false
os: linux
# Windows using conda packages
- python: "3.5"
env: USE_QT_API=PyQt5 USE_CONDA=true
os: windows
- python: "3.5"
env: USE_QT_API=PyQt4 USE_CONDA=true
os: windows
# Linux using conda packages
- python: "2.7"
env: USE_QT_API=PyQt4 USE_CONDA=true
os: linux
- python: "2.7"
env: USE_QT_API=PyQt5 USE_CONDA=true
os: linux
- python: "3.5"
env: USE_QT_API=PyQt4 USE_CONDA=true
os: linux
- python: "3.5"
env: USE_QT_API=PyQt5 USE_CONDA=true
os: linux
1 change: 0 additions & 1 deletion README

This file was deleted.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# QtPandas

### Utilities to use pandas (the data analysis/manipulation library for Python) with Qt.

## Project Information

[![Join the chat at https://gitter.im/qtpandas/Lobby#](https://badges.gitter.im/qtpandas/lobby.svg)](https://gitter.im/qtpandas/Lobby#)

## Build Status

[![Travis status](https://travis-ci.org/draperjames/QtPandas.svg?branch=master)](https://travis-ci.org/draperjames/QtPandas)

Requirements;
> Python 3.x
> Pandas 20.0
> PyQt 4.7.8

To install run the following in the command prompt;
```
pip install git+https://github.com/zbarge/QtPandas.git
pip install --upgrade git+https://github.com/robertlugg/easygui.git
```

To use, create a new Python script containing the following:
```
from PyQt4.QtCore import *
from PyQt4.QtGui import *

from pandasqt.views.CSVDialogs import CSVImportDialog

if __name__ == "__main__":
from sys import argv, exit

app = QApplication(argv)
dialog = CSVImportDialog()
dialog.show()
app.exec_()
```
Several examples can also be found in the exmples directory.

# Development

## Wanna contribute?

Join us on [gitter](https://gitter.im/qtpandas/Lobby#)

### TO DO:
- [x] Reach out to @kaotika and @datalyze-solutions
- [ ] Secure qtpandas namespace on pip.
- [ ] Wait for reply
- [ ] If no reply create new repo for QtPandas.
- [x] Create .travis.yml file.
- [x] integrate into README.md
- [ ] Add documentation.
- [ ] Add screen shots
- [ ] Create Wiki
- [ ] Make verison agnostic.
- [ ] Create specific Python version tests.
- [ ] Add Windows, Apple, and Linux tests.
- [ ] Consider adding functions seen in [Spyder IDE's dataframeeditor](https://github.com/spyder-ide/spyder/blob/f2b36f00f873cf4080087bfb529e6256b3e24792/spyder/widgets/variableexplorer/dataframeeditor.py)
- [ ] Sort
- [ ] Color coding


Forked from @datalyze-solutions's [master](https://github.com/datalyze-solutions/pandas-qt).
16 changes: 8 additions & 8 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
master_doc = 'index'

# General information about the project.
project = u'pandas-qt'
copyright = u'2014, Matthias Ludwig - Datalyze Solutions'
project = 'pandas-qt'
copyright = '2014, Matthias Ludwig - Datalyze Solutions'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -225,8 +225,8 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
('index', 'pandas-qt.tex', u'pandas-qt Documentation',
u'Matthias Ludwig - Datalyze Solutions', 'manual'),
('index', 'pandas-qt.tex', 'pandas-qt Documentation',
'Matthias Ludwig - Datalyze Solutions', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -255,8 +255,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'pandas-qt', u'pandas-qt Documentation',
[u'Matthias Ludwig - Datalyze Solutions'], 1)
('index', 'pandas-qt', 'pandas-qt Documentation',
['Matthias Ludwig - Datalyze Solutions'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -269,8 +269,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'pandas-qt', u'pandas-qt Documentation',
u'Matthias Ludwig - Datalyze Solutions', 'pandas-qt', 'One line description of project.',
('index', 'pandas-qt', 'pandas-qt Documentation',
'Matthias Ludwig - Datalyze Solutions', 'pandas-qt', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
8 changes: 4 additions & 4 deletions examples/TestApp.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dropEvent(self, event):
"""
super(DropLineEdit, self).dropEvent(event)
mimeDataPayload = event.mimeData().data()
self.setText(u"dropped column: {0}".format(mimeDataPayload.column))
self.setText("dropped column: {0}".format(mimeDataPayload.column))

class ComplexDropWidget(QtGui.QLineEdit):

Expand Down Expand Up @@ -217,13 +217,13 @@ def setModelColumn(self, index):
self.dataComboBox.setModelColumn(index)

def goToColumn(self):
print "go to column 7"
print("go to column 7")
index = self.dataTableView.view().model().index(7, 0)
self.dataTableView.view().setCurrentIndex(index)

def changeColumnValue(self, columnName, index, dtype):
print "failed to change", columnName, "to", dtype
print index.data(), index.isValid()
print("failed to change", columnName, "to", dtype)
print(index.data(), index.isValid())
self.dataTableView.view().setCurrentIndex(index)

def setFilter(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/ThreadedExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def initUI(self):

@Slot()
def debugPrint(self):
print 'THREAD %s ended' % (self.sender().name, )
print('THREAD %s ended' % (self.sender().name, ))


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion examples/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def getCsvData():
return df

def getRandomData(rows=100, columns=5):
columns = [u"column {}".format(column) for column in range(columns) ]
columns = ["column {}".format(column) for column in range(columns) ]
data = {}
for column in columns:
data[column] = numpy.random.rand(rows)
Expand Down
4 changes: 2 additions & 2 deletions pandasqt/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
sip.setapi('QTextStream', 2)
sip.setapi('QTime', 2)
sip.setapi('QUrl', 2)
except ValueError, e:
except ValueError as e:
log.error(e)

try:
from PyQt4 import QtCore as QtCore_
from PyQt4 import QtGui as QtGui_
from PyQt4.QtCore import pyqtSlot as Slot, pyqtSignal as Signal
except ImportError, e:
except ImportError as e:
from PySide import QtCore as QtCore_
from PySide import QtGui as QtGui_
from PySide.QtCore import Slot, Signal
Expand Down
10 changes: 7 additions & 3 deletions pandasqt/encoding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import os

import warnings
BASEDIR = os.path.dirname(os.path.abspath(__file__))

if sys.platform == 'win32':
Expand All @@ -12,9 +12,13 @@
try:
import magic
AUTODETECT = True
except ImportError, e:
except ImportError as e:
#if sys.platform == 'darwin':
raise ImportError('Please install libmagic')
#raise ImportError('Please install libmagic')
warnings.warn("Please install libmagic - got an error: {}".format(e))
AUTODETECT = False
except OSError as e:
warnings.warn("Detector.Issues importing libmagic - got an error: {}".format(e))
AUTODETECT = False


Expand Down
24 changes: 12 additions & 12 deletions pandasqt/excepthook.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# copied and modified from Eric IDE ( credits goes to author )

import time
import cStringIO
import io
import traceback
from pandasqt.compat import QtGui
import codecs
Expand All @@ -18,41 +18,41 @@ def excepthook(excType, excValue, tracebackobj):
@param excValue exception value
@param tracebackobj traceback object
"""
separator = u'-' * 80
separator = '-' * 80

logFile = os.path.join(tempfile.gettempdir(), "error.log")
notice = """An unhandled exception occurred. Please report the problem.\n"""
notice += """A log has been written to "{}".\n\nError information:""".format(logFile)
timeString = time.strftime("%Y-%m-%d, %H:%M:%S")

tbinfofile = cStringIO.StringIO()
tbinfofile = io.StringIO()
traceback.print_tb(tracebackobj, None, tbinfofile)
tbinfofile.seek(0)
tbinfo = tbinfofile.read()
tbinfo = tbinfo.decode('utf-8')

try:
excValueStr = str(excValue).decode('utf-8')
except UnicodeEncodeError, e:
excValueStr = unicode(excValue)
except UnicodeEncodeError as e:
excValueStr = str(excValue)

errmsg = u'{0}: \n{1}'.format(excType, excValueStr)
sections = [u'\n', separator, timeString, separator, errmsg, separator, tbinfo]
msg = u'\n'.join(sections)
errmsg = '{0}: \n{1}'.format(excType, excValueStr)
sections = ['\n', separator, timeString, separator, errmsg, separator, tbinfo]
msg = '\n'.join(sections)
try:
f = codecs.open(logFile, "a+", encoding='utf-8')
f.write(msg)
f.close()
except IOError, e:
msgbox(u"unable to write to {0}".format(logFile), u"Writing error")
except IOError as e:
msgbox("unable to write to {0}".format(logFile), "Writing error")

# always show an error message
try:
if not _isQAppRunning():
app = QtGui.QApplication([])
_showMessageBox(unicode(notice) + unicode(msg))
_showMessageBox(str(notice) + str(msg))
except:
msgbox(unicode(notice) + unicode(msg), u"Error")
msgbox(str(notice) + str(msg), "Error")

def _isQAppRunning():
if QtGui.QApplication.instance() is None:
Expand Down
4 changes: 2 additions & 2 deletions pandasqt/models/ColumnDtypeModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,15 @@ def setData(self, index, value, role=DTYPE_CHANGE_ROLE):
try:
if dtype == np.dtype('<M8[ns]'):
if currentDtype in SupportedDtypes.boolTypes():
raise Exception, u"Can't convert a boolean value into a datetime value."
raise Exception("Can't convert a boolean value into a datetime value.")
self._dataFrame[columnName] = self._dataFrame[columnName].apply(pandas.to_datetime)
else:
self._dataFrame[columnName] = self._dataFrame[columnName].astype(dtype)
self.dtypeChanged.emit(index.row(), dtype)
self.layoutChanged.emit()

return True
except Exception, e:
except Exception as e:
message = 'Could not change datatype %s of column %s to datatype %s' % (currentDtype, columnName, dtype)
self.changeFailed.emit(message, index, dtype)
raise
Expand Down
Loading