Comments (5)
a more complete solution would be to just drop all those occurences of if sys.version_info <= (3,0)
from canmatrix.
also note that
DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in Python 3.12. Use ConfigParser directly instead.
since Python3.12 has arrived, this needs to be handled somehow:
--- python-canmatrix.orig/versioneer.py
+++ python-canmatrix/versioneer.py
@@ -336,9 +336,9 @@
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
- parser = configparser.SafeConfigParser()
+ parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
- parser.readfp(f)
+ parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory
def get(parser, name):
this patch requires Python>=3.2 which is probably acceptable (or not)
from canmatrix.
in my original post, i missed that there are a few imports of the past
library (which is part of future
),
so here's a more complete patch to get rid of future
:
Index: python-canmatrix-1.0~github/setup.py
===================================================================
--- python-canmatrix-1.0~github.orig/setup.py
+++ python-canmatrix-1.0~github/setup.py
@@ -83,7 +83,6 @@ setup(
"attrs>=19.2.0",
"click",
"enum34; python_version < '3.4'",
- "future",
"importlib-metadata; python_version < '3.8'",
"six",
"typing; python_version < '3.5'",
Index: python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/sym.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
@@ -100,11 +100,7 @@ def format_float(f): # type: (typing.An
def create_signal(db, signal): # type: (canmatrix.CanMatrix, canmatrix.Signal) -> str
output = ""
- if sys.version_info > (3, 0):
- quote_name = not signal.name.isidentifier()
- else:
- from future.utils import isidentifier
- quote_name = not isidentifier(signal.name)
+ quote_name = not signal.name.isidentifier()
if quote_name:
output += 'Var="%s" ' % signal.name
else:
Index: python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/canmatrix.py
+++ python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
@@ -40,7 +40,6 @@ import warnings
from builtins import *
import attr
-from past.builtins import basestring
from six.moves import zip_longest
import canmatrix.copy
@@ -432,7 +431,7 @@ class Signal(object):
if not (self.min <= value <= self.max):
value = self.min
- if isinstance(value, basestring):
+ if isinstance(value, str):
for value_key, value_string in self.values.items():
if value_string == value:
value = value_key
Index: python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/xls.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
@@ -30,7 +30,6 @@ import logging
import typing
from builtins import *
-import past.builtins
import xlrd
import xlwt
@@ -540,7 +539,7 @@ def load(file, **options):
unit = ""
factor = sh.cell(row_num, index['function']).value
- if isinstance(factor, past.builtins.basestring):
+ if isinstance(factor, str):
factor = factor.strip()
if " " in factor and factor[0].isdigit():
(factor, unit) = factor.strip().split(" ", 1)
Index: python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/yaml.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
@@ -30,7 +30,6 @@ import typing
from builtins import *
import yaml
-from past.builtins import long, unicode
import canmatrix
@@ -43,8 +42,6 @@ except ImportError:
representers = False
try:
yaml.add_representer(int, SafeRepresenter.represent_int)
- yaml.add_representer(long, SafeRepresenter.represent_long)
- yaml.add_representer(unicode, SafeRepresenter.represent_unicode)
yaml.add_representer(str, SafeRepresenter.represent_unicode)
yaml.add_representer(list, SafeRepresenter.represent_list)
representers = True
@@ -67,7 +64,7 @@ def dump(db, f, **options): # type: (ca
# f = open(filename, "w")
if representers:
- f.write(unicode(yaml.dump(new_db)))
+ f.write(yaml.dump(new_db))
else:
f.write(yaml.dump(new_db).encode('utf8'))
Index: python-canmatrix-1.0~github/mypy.ini
===================================================================
--- python-canmatrix-1.0~github.orig/mypy.ini
+++ python-canmatrix-1.0~github/mypy.ini
@@ -34,5 +34,5 @@ ignore_errors = True
ignore_errors = True
# other settings:
-[mypy-xlsxwriter,past,past.builtins,pathlib2]
+[mypy-xlsxwriter,pathlib2]
ignore_missing_imports = True
notes
- the patch in this comment is only concerned about the
future
module (and not about theconfigparser
in the other comment) - i've replaced
isinstance(x, basestring)
withisinstance(x, str)
, asbasestring
was typically used to check whether a value was eitherstr
orunicode
(which are bothstr
in Py3). However, IIRCbasestring
is also the base class forbytes
(at leastisinstance(b'foo', past.builtins.basestring)
yieldsTrue
), so the new test might miss some cases...
from canmatrix.
Hi @umlaeute ,
thanks for your help.
And yes, you are right.
I created 2 pull requests for your patches:
#744
#745
Thanks again
from canmatrix.
sorry to have created additional work.
i could (and would) of course have done the PRs myself, but wanted to get your feedback first to see if i was on the right track (and it was easier for my actual workflow (while preparing the Debian packages) to just paste the diffs for now)
from canmatrix.
Related Issues (20)
- Many errors are reported when parsing the dbc with Chinese characters and special characters HOT 4
- Release 0.9.5 have been renamed to 1.0 in github releases HOT 3
- Convert arxml file to dbc file wrong HOT 6
- Wrong min/max scaling when signal has slope or offset HOT 1
- Loading arxml with Ethernet data Performance is extremely bad on development branch(2023-12-15) HOT 6
- use Canmatrix create dbc HOT 7
- Convert excel to DBC with Canmatrix HOT 1
- Convert DBC to arxml failed HOT 3
- Renaming Node / ECU via rename_ecu should clear out any existing transmitter and receiver HOT 1
- wrong with canmatrix.cli.compare.cli_compare
- when xsl2dbc,singal's offset γmini is uncorrect
- convert ARXML to DBC have error:<class 'decimal.DivisionUndefined'> HOT 1
- convert ARXML to DBC have error:<class 'decimal.DivisionUndefined'> HOT 2
- Convert dbc <=> xlsx - units are deleted HOT 1
- Convert dbc <=> xlsx - DLC is always reset to it's maximum of 8 bytes HOT 1
- Exporting ARXML to XLSX (CanCluster vs. J1939Cluster) HOT 6
- canmatrix.py --> decimal.InvalidOperation: [<class 'decimal.DivisionUndefined'>] HOT 7
- Speed up Decode and Encode timing
- ARXML to xlsx HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from canmatrix.