public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
From: Brian Inglis <Brian.Inglis@Shaw.ca>
To: cygwin-apps@cygwin.com
Cc: Jari Aalto <jari.aalto@cante.net>
Subject: Re: ITA xlsx2csv (was Re: python2 removal)
Date: Thu, 16 Mar 2023 09:53:20 -0600	[thread overview]
Message-ID: <efc4f3db-47e8-1743-1bb9-5966e74b247e@Shaw.ca> (raw)
In-Reply-To: <2f49719c-aff9-8053-bb6d-cea25b150fd3@dronecode.org.uk>

[-- Attachment #1: Type: text/plain, Size: 3231 bytes --]

On 2023-03-16 07:29, Jon Turney wrote:
> On 15/03/2023 12:56, Brian Inglis via Cygwin-apps wrote:
>> On 2023-03-14 13:17, Jon Turney via Cygwin-apps wrote:
>>> On 15/01/2023 12:52, Jon Turney via Cygwin-apps wrote:
>>>> This has come up in discussion a few times, and is now well overdue, I think.
>>>> Python 2.7 is the last python2 version, which was sunsetted on January 1, 2020.

>>>> 3) There might also still be some other packages lurking which just install 
>>>> a script with a shebang containing 'python', and assume that python is 
>>>> python2. I don't know how we could identify those.

>>> The remaining cases of packages which have a dependency on python and/or 
>>> python2 are either this (packages which contain a python script with a python 
>>> shebang line), or the other case which I hadn't previously considered - a 
>>> package which contain an executable or shared library linked with 
>>> libpython2.7.dll.
>>> So, again I need inspect these to determine what should happen to them.

>> I'd like to adopt *xlsx2csv* - for an initial build see:

> Jari is still the maintainer of record for that package, so I need to give him 
> an opportunity to reply here.

>> https://cygwin.com/cgi-bin2/jobs.cgi?id=5607
>> https://cygwin.com/cgit/cygwin-packages/playground/commit/?id=af279166a903b526274f8b10264e206fc5010a68
>> https://github.com/cygwin/scallywag/actions/runs/4419738199
>> The author remains the same but version numbering staggers around then jumps 
>> to 0.5 and is now up to 0.8.1.
>> The manual was a POD file from Jari run thru pod2man for 0.11 from 2010, but 
>> very outdated now, not to mention using Perl docs for Python modules, so I'm 
>> rewriting from help2man output to be current, comprehensive, and functional 
>> with `groff -man`.
>> [I use it to get data into portable form, make it threat free, and fake 
>> spreadsheets for my accountant, if I want to use gvim instead of Gnumeric or 
>> Libre Office calc! ;^> ]

> The critical piece of data I'm missing here is which of these is true:
> a) This package contains a script with a python shebang. The current version 
> doesn't work when python is python3, so an upgrade is needed to continue working 
> when python2 is removed, or
> b) This package contains a script with a python shebang. The current version 
> will continue to work when python is python3.

Unfortunately only a generic cygbuild sh script is supplied with the package - 
does nothing but complain without some other "magic" script or data! ;^>
Jari's Debian 8/9 xlsx2csv releases have been updated to 0.20+20161027 from 
0.11+20120814.

$ sed 1q xlsx2csv.py
#!/usr/bin/env python

Does not work with python3, nor after running 2to3 fixes - see attached logs - 
IANAPythonista

Anyway pylint was not useful compared to 2to3 - see attached pylint before and 
after 2to3 logs compared to 2to3 log.

-- 
Take care. Thanks, Brian Inglis              Calgary, Alberta, Canada

La perfection est atteinte                   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer     but when there is no more to cut
                                 -- Antoine de Saint-Exupéry

[-- Attachment #2: xlsx2csv-pylint-2.log --]
[-- Type: text/plain, Size: 198 bytes --]

************* Module xlsx2csv.py
xlsx2csv.py.bak:286:65: E0001: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers (<unknown>, line 286) (syntax-error)

[-- Attachment #3: xlsx2csv-2to3.log --]
[-- Type: text/plain, Size: 6228 bytes --]

RefactoringTool: Adding transformation: apply
RefactoringTool: Adding transformation: asserts
RefactoringTool: Adding transformation: basestring
RefactoringTool: Skipping optional fixer: buffer
RefactoringTool: Adding transformation: dict
RefactoringTool: Adding transformation: except
RefactoringTool: Adding transformation: exec
RefactoringTool: Adding transformation: execfile
RefactoringTool: Adding transformation: exitfunc
RefactoringTool: Adding transformation: filter
RefactoringTool: Adding transformation: funcattrs
RefactoringTool: Adding transformation: future
RefactoringTool: Adding transformation: getcwdu
RefactoringTool: Adding transformation: has_key
RefactoringTool: Skipping optional fixer: idioms
RefactoringTool: Adding transformation: import
RefactoringTool: Adding transformation: imports
RefactoringTool: Adding transformation: imports2
RefactoringTool: Adding transformation: input
RefactoringTool: Adding transformation: intern
RefactoringTool: Adding transformation: isinstance
RefactoringTool: Adding transformation: itertools
RefactoringTool: Adding transformation: itertools_imports
RefactoringTool: Adding transformation: long
RefactoringTool: Adding transformation: map
RefactoringTool: Adding transformation: metaclass
RefactoringTool: Adding transformation: methodattrs
RefactoringTool: Adding transformation: ne
RefactoringTool: Adding transformation: next
RefactoringTool: Adding transformation: nonzero
RefactoringTool: Adding transformation: numliterals
RefactoringTool: Adding transformation: operator
RefactoringTool: Adding transformation: paren
RefactoringTool: Adding transformation: print
RefactoringTool: Adding transformation: raise
RefactoringTool: Adding transformation: raw_input
RefactoringTool: Adding transformation: reduce
RefactoringTool: Adding transformation: reload
RefactoringTool: Adding transformation: renames
RefactoringTool: Adding transformation: repr
RefactoringTool: Skipping optional fixer: set_literal
RefactoringTool: Adding transformation: standarderror
RefactoringTool: Adding transformation: sys_exc
RefactoringTool: Adding transformation: throw
RefactoringTool: Adding transformation: tuple_params
RefactoringTool: Adding transformation: types
RefactoringTool: Adding transformation: unicode
RefactoringTool: Adding transformation: urllib
RefactoringTool: Skipping optional fixer: ws_comma
RefactoringTool: Adding transformation: xrange
RefactoringTool: Adding transformation: xreadlines
RefactoringTool: Adding transformation: zip
RefactoringTool: Refactoring xlsx2csv.py
RefactoringTool: Refactored xlsx2csv.py
RefactoringTool: Wrote changes to xlsx2csv.py
RefactoringTool: Files that were modified:
RefactoringTool: xlsx2csv.py
--- xlsx2csv.py	(original)
+++ xlsx2csv.py	(refactored)
@@ -148,10 +148,10 @@
             attrs = sheetNode._attrs
             name = attrs["name"].value
             if self.appName == 'xl':
-                if attrs.has_key('r:id'): id = int(attrs["r:id"].value[3:])
+                if 'r:id' in attrs: id = int(attrs["r:id"].value[3:])
                 else: id = int(attrs['sheetId'].value)
             else:
-                if attrs.has_key('sheetId'): id = int(attrs["sheetId"].value)
+                if 'sheetId' in attrs: id = int(attrs["sheetId"].value)
                 else: id = int(attrs['r:id'].value[3:])
             self.sheets.append({'name': name, 'id': id})
 
@@ -272,18 +272,18 @@
                 # get cell format
                 format = None
                 xfs_numfmt = self.styles.cellXfs[s]
-                if self.styles.numFmts.has_key(xfs_numfmt):
+                if xfs_numfmt in self.styles.numFmts:
                     format = self.styles.numFmts[xfs_numfmt]
-                elif STANDARD_FORMATS.has_key(xfs_numfmt):
+                elif xfs_numfmt in STANDARD_FORMATS:
                     format = STANDARD_FORMATS[xfs_numfmt]
                 # get format type
-                if format and FORMATS.has_key(format):
+                if format and format in FORMATS:
                     format_type = FORMATS[format]
 
                     if format_type == 'date': # date/time
                         try:
                             if self.workbook.date1904:
-                                date = datetime.datetime(1904, 01, 01) + datetime.timedelta(float(data))
+                                date = datetime.datetime(1904, 0o1, 0o1) + datetime.timedelta(float(data))
                             else:
                                 date = datetime.datetime(1899, 12, 30) + datetime.timedelta(float(data))
                             if self.dateformat:
@@ -322,12 +322,12 @@
             self.in_cell_value = True
         #elif self.in_cell and name == 'f':
         #    self.in_cell_formula = True
-        elif self.in_sheet and name == 'row' and attrs.has_key('r'):
+        elif self.in_sheet and name == 'row' and 'r' in attrs:
             self.rowNum = attrs['r']
             self.in_row = True
             self.columns = {}
             self.spans = None
-            if attrs.has_key('spans'):
+            if 'spans' in attrs:
                 self.spans = [int(i) for i in attrs['spans'].split(":")]
         elif name == 'sheetData':
             self.in_sheet = True
@@ -343,9 +343,9 @@
             self.columns[t - 1 + self.colIndex] = self.data
             self.in_cell = False
         if self.in_row and name == 'row':
-            if len(self.columns.keys()) > 0:
+            if len(list(self.columns.keys())) > 0:
                 d = [""] * (max(self.columns.keys()) + 1)
-                for k in self.columns.keys():
+                for k in list(self.columns.keys()):
                     d[k] = self.columns[k].encode("utf-8")
                 if self.spans:
                     l = self.spans[0] + self.spans[1] - 1
@@ -366,7 +366,7 @@
         else:
             if fullpath.lower().endswith(".xlsx"):
                 outfilepath = fullpath[:-4] + 'csv'
-                print("Converting %s to %s" %(fullpath, outfilepath))
+                print(("Converting %s to %s" %(fullpath, outfilepath)))
                 f = open(outfilepath, 'w+b')
                 try:
                     xlsx2csv(fullpath, f, **kwargs)

[-- Attachment #4: xlsx2csv-pylint-3.log --]
[-- Type: text/plain, Size: 371 bytes --]

************* Module xlsx2csv
xlsx2csv.py:140:27: E1101: Instance of 'Document' has no 'firstChild' member (no-member)
xlsx2csv.py:142:28: E1101: Instance of 'Document' has no 'firstChild' member (no-member)
xlsx2csv.py:146:17: E1101: Instance of 'Document' has no 'firstChild' member (no-member)

-----------------------------------
Your code has been rated at 9.44/10


  reply	other threads:[~2023-03-16 15:53 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-15 12:52 python2 removal Jon Turney
2023-01-15 19:31 ` Ken Brown
2023-01-16 12:49   ` Jon Turney
2023-01-16 14:22     ` Ken Brown
2023-01-16 12:49 ` Jon Turney
2023-02-25 16:23   ` Jon Turney
2023-02-25 16:51     ` Adam Dinwoodie
2023-02-26 11:56       ` Jon Turney
2023-04-30 18:25       ` Jon Turney
2023-04-30 20:32         ` Adam Dinwoodie
2023-05-01 17:53           ` Jon Turney
2023-02-25 16:23   ` Jon Turney
     [not found]     ` <003a01d94a86$750f4b70$5f2de250$@samsung.com>
2023-02-27 13:36       ` Jon Turney
2023-02-25 16:23   ` Jon Turney
2023-03-07 17:27   ` Jon Turney
2023-01-17  2:27 ` David Rothenberger
2023-03-14 19:16 ` Jon Turney
2023-03-14 19:17 ` Jon Turney
2023-03-15 12:56   ` Brian Inglis
2023-03-15 16:46     ` marco atzeri
2023-03-16 13:29     ` ITA (was Re: python2 removal) Jon Turney
2023-03-16 15:53       ` Brian Inglis [this message]
2023-03-16 18:57         ` ITA xlsx2csv " Jon Turney
2023-03-16 21:12           ` Brian Inglis
2023-03-22  7:36           ` Jari Aalto
2023-03-22 16:23             ` Jon Turney
2023-04-02 15:47   ` python2 removal Jon Turney
2023-04-02 15:55     ` Jon Turney
2023-06-01 16:54       ` Jon Turney
2023-04-02 16:00     ` Jon Turney
2023-04-03  1:08     ` marco atzeri
2023-04-11  6:49       ` Marco Atzeri
2023-06-04 19:17     ` Jon Turney
2023-07-02 14:30       ` Jon Turney
2023-07-07 18:54         ` Marco Atzeri
2023-07-09 16:50           ` Jon Turney
2024-01-18 19:31             ` Jon Turney
2024-01-18 19:40               ` Jon Turney
2024-01-19 18:23                 ` Hamish McIntyre-Bhatty
2024-04-10 19:19                   ` Hamish McIntyre-Bhatty
2024-04-11 12:23                     ` Jon Turney
2023-06-11 18:06     ` Jon Turney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=efc4f3db-47e8-1743-1bb9-5966e74b247e@Shaw.ca \
    --to=brian.inglis@shaw.ca \
    --cc=cygwin-apps@cygwin.com \
    --cc=jari.aalto@cante.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).