Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request boriel-basic#278 from boriel/feature/drop_six
Browse files Browse the repository at this point in the history
Drop six module usage
  • Loading branch information
boriel committed May 2, 2020
2 parents cc2d2bf + a38c774 commit 5287030
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 15 deletions.
5 changes: 1 addition & 4 deletions api/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import six
from . import global_
from . import errmsg

Expand All @@ -22,8 +21,6 @@ def read_txt_file(fname):
for i in encodings:
try:
result = content.decode(i)
if six.PY2:
result = result.encode('utf-8')
return result
except UnicodeDecodeError:
pass
Expand All @@ -40,7 +37,7 @@ def open_file(fname, mode='rb', encoding='utf-8'):
:param encoding: optional encoding (string). Ignored in python2 or if not in text mode
:return: an open file handle
"""
if six.PY2 or 't' not in mode:
if 't' not in mode:
kwargs = {}
else:
kwargs = {'encoding': encoding}
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
ply==3.11
six

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ def get_files(folders):
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
install_requires=['six', 'ply'],
install_requires=['ply'],
tags=['BASIC', 'zxspectrum', 'compiler', 'z80']
)
8 changes: 3 additions & 5 deletions symbols/string_.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
# the GNU General License
# ----------------------------------------------------------------------

import six

from api.constants import CLASS
from .symbol_ import Symbol
from .type_ import Type
Expand Down Expand Up @@ -44,21 +42,21 @@ def __repr__(self):
return '"%s"' % str(self)

def __eq__(self, other):
if isinstance(other, six.string_types):
if isinstance(other, str):
return self.value == other

assert isinstance(other, SymbolSTRING)
return self.value == other.value

def __gt__(self, other):
if type(other) in six.string_types:
if isinstance(other, str):
return self.value > other

assert isinstance(other, SymbolSTRING)
return self.value > other.value

def __lt__(self, other):
if type(other) in six.string_types:
if isinstance(other, str):
return self.value < other

assert isinstance(other, SymbolSTRING)
Expand Down
5 changes: 3 additions & 2 deletions tests/functional/test_.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
# vim:ts=4:et:ai

import sys
import six
import os
import doctest
import test

from io import StringIO

class OutputProxy(six.StringIO):

class OutputProxy(StringIO):
"""A simple interface to replace sys.stdout so
doctest can capture it.
"""
Expand Down
2 changes: 1 addition & 1 deletion zxb.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
import argparse

from six import StringIO
from io import StringIO

import api.debug
import api.config
Expand Down
2 changes: 1 addition & 1 deletion zxblex.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def is_label(token):
return column == 1


lexer = lex.lex(lextab='parsetab.zxblextab')
lexer = lex.lex()

if __name__ == '__main__': # For testing purposes
lexer.input(open(sys.argv[1], 'rt').read())
Expand Down

0 comments on commit 5287030

Please sign in to comment.