Re: lilyglyphs: Python 2 deprecation

2019-11-12 Thread Urs Liska



Am 12. November 2019 10:50:45 MEZ schrieb David Kastrup :
>Werner LEMBERG  writes:
>
 This package is written by Urs Liska , who is
 quite busy these days.  In case you have experience with Python 2
 to 3 conversion, please help produce a new version!
>>> 
>>> Should it still be backwards compatible with Python 2.7 if possible
>or
>>> is it ok to drop Python2 backwards compatibility completely? Option
>>> one is possible, option two gives cleaner code, and is easier to
>>> maintain in future.
>>
>> I favour option one.  Inspite of the announced `death' of Python 2
>I'm
>> quite sure that this version series will stay for many years.
>

I wouldn't see the need for backwatd compatibility, but I must admit I haven't 
thought about the issue too much.

>With regard to GUB, 2.7 compatibility makes for a much nicer transition
>period.  But GUB is not likely involved in uses of that package

Correct, lilyglyphs doesn't play any role in creating or building LilyPond. 

Urs

> which
>seems to be mainly used in a TeXlive context.  I haven't checked, but I
>think that TeXlive is pretty much prepared to use Python3.

-- 
Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.



Re: lilyglyphs: Python 2 deprecation

2019-11-12 Thread David Kastrup
Werner LEMBERG  writes:

>>> This package is written by Urs Liska , who is
>>> quite busy these days.  In case you have experience with Python 2
>>> to 3 conversion, please help produce a new version!
>> 
>> Should it still be backwards compatible with Python 2.7 if possible or
>> is it ok to drop Python2 backwards compatibility completely? Option
>> one is possible, option two gives cleaner code, and is easier to
>> maintain in future.
>
> I favour option one.  Inspite of the announced `death' of Python 2 I'm
> quite sure that this version series will stay for many years.

With regard to GUB, 2.7 compatibility makes for a much nicer transition
period.  But GUB is not likely involved in uses of that package which
seems to be mainly used in a TeXlive context.  I haven't checked, but I
think that TeXlive is pretty much prepared to use Python3.

-- 
David Kastrup



Re: lilyglyphs: Python 2 deprecation

2019-11-12 Thread Werner LEMBERG


>> This package is written by Urs Liska , who is
>> quite busy these days.  In case you have experience with Python 2
>> to 3 conversion, please help produce a new version!
> 
> Should it still be backwards compatible with Python 2.7 if possible or
> is it ok to drop Python2 backwards compatibility completely? Option
> one is possible, option two gives cleaner code, and is easier to
> maintain in future.

I favour option one.  Inspite of the announced `death' of Python 2 I'm
quite sure that this version series will stay for many years.


Werner



Re: lilyglyphs: Python 2 deprecation

2019-11-11 Thread Martin Tarenskeen



On Tue, 12 Nov 2019, Werner LEMBERG wrote:


 If you are the maintainer of any of these packages, and still are using
 Python2, please try to update to Python3 as soon as possible.

   ...
   lilyglyphs/
 py2 only
 lilyglyphs/lily-glyph-commands.py
 lilyglyphs/lily-image-commands.py
 lilyglyphs/lily-rebuild-pdfs.py
 lilyglyphs/lilyglyphs_common.py
   ...


I ran the 2to3 command on the python scripts from 
https://github.com/uliska/lilyglyphs/tree/master/scripts


Without having tested it the output ouput shows me 3 types of issues that 
need fixing. The most frequent one is the print command that needs to be 
replaced with print ().


1. print vs print()
2. raw_input() vs input()
3. something with iterkeys() vs keys() in sorted()

I have attached the output of "2to3 *.py" where you see what I mean.
Maybe someone who knows how to use git can take a look?

--

MT--- deploy.py   (original)
+++ deploy.py   (refactored)
@@ -55,9 +55,9 @@
 def main():
 
 if os.path.exists('deploy'):
-overwrite = raw_input('deploy directory exists. Overwrite? ')
+overwrite = input('deploy directory exists. Overwrite? ')
 if overwrite != 'y':
-print 'Aborted'
+print('Aborted')
 sys.exit(1)
 shutil.rmtree('deploy')
 os.mkdir('deploy')
@@ -65,7 +65,7 @@
 
 # now we're guaranteed to have an empty 'deploy/lilyglyphs' directory
 
-print 'Copying files:'
+print('Copying files:')
 # copy individual files from the root directory
 cp_root()
 # copy complete directories to their corresponding dest
@@ -140,12 +140,12 @@
 global manifest
 if not dest:
 dest = src
-print '-', src
+print('-', src)
 shutil.copytree(src, dir_deploy + '/' + dest)
 append_manifest(src, dest)
 
 def cp_root():
-print '- root'
+print('- root')
 f = []
 f.append('CHANGES.md')
 f.append('INSTALL')
@@ -153,7 +153,7 @@
 copy_files(f, '')
 
 def cp_scripts():
-print '- scripts'
+print('- scripts')
 os.mkdir(dir_deploy + '/bin')
 os.mkdir(dir_deploy + '/lib')
 for file in os.listdir('scripts'):
@@ -165,7 +165,7 @@
 manifest.append('/lib/' + file)
 
 def lg_private():
-print '- lilyglyphs_private'
+print('- lilyglyphs_private')
 zip = zipfile.ZipFile(dir_deploy + 
'/documentation/lilyglyphs_private.zip', 'w')
 for root, dirs, files in os.walk('lilyglyphs_private'):
 for file in files:
@@ -216,15 +216,15 @@
 for part in version_parts:
 int(part)
 except:
-print 'Malformed version argument:', version
-print 'Use three integers separated by dots'
+print('Malformed version argument:', version)
+print('Use three integers separated by dots')
 sys.exit(1)
 
-print 'Preparing lilyglyphs deployment', version + '.'
-print 'CWD is', os.getcwd()
-print 'This should be the root of lilyglyphs.'
-print 'This script will not work on Windows.'
-check = raw_input('Proceed (y/..)? ')
+print('Preparing lilyglyphs deployment', version + '.')
+print('CWD is', os.getcwd())
+print('This should be the root of lilyglyphs.')
+print('This script will not work on Windows.')
+check = input('Proceed (y/..)? ')
 if check != 'y':
 sys.exit(1)
 
--- lily-glyph-commands.py  (original)
+++ lily-glyph-commands.py  (refactored)
@@ -80,10 +80,10 @@
 if not len(line):
 # skip if cmd and glyph haven't been filled both
 if not (entry['cmd'] and entry['element']):
-print 'Skip malformed entry \'' + entry['cmd'] + '\'. Please 
check input file'
+print('Skip malformed entry \'' + entry['cmd'] + '\'. Please 
check input file')
 reset_entry()
 else:
-print 'Read entry \'' + entry['cmd'] + '\''
+print('Read entry \'' + entry['cmd'] + '\'')
 lg.in_cmds[entry['cmd']] = {}
 lg.in_cmds[entry['cmd']]['element'] = entry['element']
 lg.in_cmds[entry['cmd']]['type'] = entry['type']
@@ -110,13 +110,13 @@
 
 
 def usage():
-print 'genGlyphCommands.py'
-print 'is part of the lilyglyphs package'
-print ''
-print 'Usage:'
-print 'Pass the name (without path) of an input definitions file'
-print '(this has to be located in the /stash_new_commands directory.'
-print 'Please refer to the manual (documentation/lilyglyphs.pdf).'
+print('genGlyphCommands.py')
+print('is part of the lilyglyphs package')
+print('')
+print('Usage:')
+print('Pass the name (without path) of an input definitions file')
+print('(this has to be located in the /stash_new_commands directory.')
+print('Please refer to the manual (documentation/lilyglyphs.pdf).')
 
 # 
 # Finally launch the program
--- lilyglyphs_common.py  

Re: lilyglyphs: Python 2 deprecation

2019-11-11 Thread Martin Tarenskeen




On Tue, 12 Nov 2019, Werner LEMBERG wrote:


 If you are the maintainer of any of these packages, and still are using
 Python2, please try to update to Python3 as soon as possible.

   ...
   lilyglyphs/
 py2 only
 lilyglyphs/lily-glyph-commands.py
 lilyglyphs/lily-image-commands.py
 lilyglyphs/lily-rebuild-pdfs.py
 lilyglyphs/lilyglyphs_common.py
   ...

This package is written by Urs Liska , who is
quite busy these days.  In case you have experience with Python 2 to 3
conversion, please help produce a new version!


Should it still be backwards compatible with Python 2.7 if possible or is 
it ok to drop Python2 backwards compatibility completely? Option one is 
possible, option two gives cleaner code, and is easier to maintain in 
future.


MT




lilyglyphs: Python 2 deprecation

2019-11-11 Thread Werner LEMBERG


On the TeXLive mailing list, Norbert Preining , one
of the maintainers of TeXLive posted the following today.

  With the end of 2019, Python2 will be deprecated and not receive any
  security updates.  Most distributions will throw out Python2
  completely.  (Don't ask me about my opinion on the whole Py2/Py3
  mess ...)

  We have quite a lot of scripts in TeX Live that are Python2 only,
  and we should seriously do some work on getting that fixed, rather
  soon.

  I have started a list of packages/scripts I found that require python,
  and tried to check which version they need, see below list.
 
  If you are the maintainer of any of these packages, and still are using
  Python2, please try to update to Python3 as soon as possible.

...
lilyglyphs/
  py2 only
  lilyglyphs/lily-glyph-commands.py
  lilyglyphs/lily-image-commands.py
  lilyglyphs/lily-rebuild-pdfs.py
  lilyglyphs/lilyglyphs_common.py
...

This package is written by Urs Liska , who is
quite busy these days.  In case you have experience with Python 2 to 3
conversion, please help produce a new version!


Werner