Difference between revisions of "User:Alvonruff/Python2.7 Futurize"

From ISFDB
Jump to navigation Jump to search
Line 45: Line 45:
 
     output = output.decode('utf8', 'ignore')
 
     output = output.decode('utf8', 'ignore')
 
     cnvyear = cnvyear.decode('utf8', 'ignore')
 
     cnvyear = cnvyear.decode('utf8', 'ignore')
 +
 +
Both of these changes merely allows the script to complete, as it does not output the offending characters. Need to find the real fix.
 +
 +
===Publications===
 +
'''Issue:''' When printing the contents of a publication (magazine, anthology, collection), an exception occurs whenever a title contains (not an exhaustive list): Italian, German.
 +
 +
'''Examples:''' https://www.isfdb2.org/cgi-bin/p3/pl.cgi?713111
 +
 +
'''Workarounds:'''
 +
In PrintTitleLine (biblio/pl.py), just after adding COVERART:
 +
    output = output.decode('utf8', 'ignore')
 +
 +
Also in PrintTitleLine (biblio/pl.py), in the section which prints the parent title:
 +
    output = output.decode('utf8', 'ignore')
  
 
Both of these changes merely allows the script to complete, as it does not output the offending characters. Need to find the real fix.
 
Both of these changes merely allows the script to complete, as it does not output the offending characters. Need to find the real fix.

Revision as of 08:33, 15 September 2022

Prerequisites

  • pip2 install future
  • pip2 install six

Conversion

  • Within the target directory (biblio, common, edit, etc), create a new directory called FUTURIZE
  • Create a shell script which lists all py files in the target directory, and turn it into a futurize command as shown below. This will create a modified version of the file in the local FUTURIZE directory.
   set -x
   futurize adv_identifier_search.py -n -w -o FUTURIZE
   futurize adv_notes_search.py -n -w -o FUTURIZE
   futurize advSearchClass.py -n -w -o FUTURIZE
   futurize adv_search_menu.py -n -w -o FUTURIZE
   futurize adv_search_results.py -n -w -o FUTURIZE
   ...
  • Edit each of the output files, and move any import lines of the form "from __future__ import xxx" below the top comment block. The first line of the comment block contains the poundbang statement, which tells the OS that it should use python to interpret the file. The poundbang statement must be the first line of the file, but futurize will place some of the import statements before the poundbang, causing a runtime error.
  • You are now free to replace specific files within the target directory with its futurized version. You may want to keep a directory containing original versions of the files, so that you may revert to its original state if some disaster ensues.

Issues

Pound Pricing

Issue: When printing publication details, an exception occurs whenever the pricing is in British Pounds. It's curious that the publication note can have information utilizing the Pound symbol, but the Price field fails.

Example: https://www.isfdb2.org/cgi-bin/p3/pl.cgi?911384

Workaround: At the beginning of ISFDBPrice (common/library.py) place:

   price = price.decode('utf8', 'ignore')

This merely allows the script to complete, as it does not output a Pound symbol. Need to find the real fix.

Titles and Variant Titles

Issue: When printing a title or variant title, an exception occurs whenever the variant title contains (not an exhaustive list): Italian, German.

Examples:

https://isfdb2.org/cgi-bin/p3/ea.cgi?26

https://isfdb2.org/cgi-bin/p3/ea.cgi?342790

Workarounds: In buildCoreTitleLine (biblio/common.py), just after the comment to "Convert special years to strings" place:

   output = output.decode('utf8', 'ignore')
   cnvyear = cnvyear.decode('utf8', 'ignore')

In displayVariantTitle (biblio/common.py), just after the comment to "Convert special years to strings" place:

   output = output.decode('utf8', 'ignore')
   cnvyear = cnvyear.decode('utf8', 'ignore')

Both of these changes merely allows the script to complete, as it does not output the offending characters. Need to find the real fix.

Publications

Issue: When printing the contents of a publication (magazine, anthology, collection), an exception occurs whenever a title contains (not an exhaustive list): Italian, German.

Examples: https://www.isfdb2.org/cgi-bin/p3/pl.cgi?713111

Workarounds: In PrintTitleLine (biblio/pl.py), just after adding COVERART:

   output = output.decode('utf8', 'ignore')

Also in PrintTitleLine (biblio/pl.py), in the section which prints the parent title:

   output = output.decode('utf8', 'ignore')

Both of these changes merely allows the script to complete, as it does not output the offending characters. Need to find the real fix.