Permalink
Browse files

opening files in python3

  • Loading branch information...
1 parent 75f76ec commit c590e98ce5848b2ec364e2caf6cfdf278b56e661 @diegosarmentero diegosarmentero committed Oct 6, 2012
@@ -16,6 +16,7 @@
# along with NINJA-IDE; If not, see <http://www.gnu.org/licenses/>.
from __future__ import unicode_literals
+import sys
import os
import re
import threading
@@ -25,6 +26,11 @@
from ninja_ide.core import settings
+if sys.version_info.major == 3:
+ python3 = True
+else:
+ python3 = False
+
#Lock to protect the file's writing operation
file_store_content_lock = threading.Lock()
@@ -148,7 +154,9 @@ def read_file_content(fileName):
with open(fileName, mode='rU') as f:
content = f.read()
encoding = get_file_encoding(content)
- content.decode(encoding)
+ print(python3)
+ if not python3:
+ content.decode(encoding)
except IOError as reason:
raise NinjaIOException(reason)
return content
@@ -92,6 +92,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number)
for space.
"""
+from __future__ import unicode_literals
__version__ = '1.3.4a0'
@@ -308,8 +308,8 @@ def _sync_tab_icon_notification_signal(self):
else:
self.emit(SIGNAL("cleanDocument(QPlainTextEdit)"), self)
if self.highlighter:
- lines = list(set(self.errors.errorsSummary.keys() +
- self.pep8.pep8checks.keys()))
+ lines = list(set(list(self.errors.errorsSummary.keys()) +
+ list(self.pep8.pep8checks.keys())))
self.highlighter.rehighlight_lines(lines)
def has_write_permission(self):
@@ -76,8 +76,6 @@ def run(self):
message += [m.message % m.message_args]
self.errorsSummary[lineno] = message
except Exception as reason:
- print(repr(reason))
- raise
message = ''
if hasattr(reason, 'msg'):
message = reason.msg
@@ -260,7 +260,8 @@ def move_tab_to_next_split(self, tab_from):
def add_editor(self, fileName="", project=None, tabIndex=None,
syntax=None, use_open_highlight=False):
- project_obj = self._parent.explorer.get_project_given_filename(fileName)
+ project_obj = self._parent.explorer.get_project_given_filename(
+ fileName)
editorWidget = editor.create_editor(fileName=fileName, project=project,
syntax=syntax, use_open_highlight=use_open_highlight,
project_obj=project_obj)
@@ -512,6 +513,7 @@ def __open_file(self, fileName='', cursorPosition=-1,
QMessageBox.information(self,
self.tr("The file couldn't be open"), reason)
except Exception as reason:
+ raise
logger.error('open_file: %s', reason)
self.actualTab.notOpening = True

0 comments on commit c590e98

Please sign in to comment.