[KCharSelect] Port generate-datafile.py to Python 3
ClosedPublic

Authored by cfeck on Jun 20 2018, 11:03 PM.

Details

Summary
  • Add missing parentheses for print()
  • Writing strings to the data file requires encode()
  • Replace "map.has_key(key)" with "key in map"
Test Plan

Tested with Unicode 11.0 data.

Diff Detail

Repository
R236 KWidgetsAddons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
cfeck created this revision.Jun 20 2018, 11:03 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 20 2018, 11:03 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
cfeck requested review of this revision.Jun 20 2018, 11:03 PM
lbeltrame accepted this revision.Jun 21 2018, 4:44 AM
This revision is now accepted and ready to land.Jun 21 2018, 4:44 AM
cfeck planned changes to this revision.Jun 21 2018, 8:51 PM

Needs more changes :/

cfeck updated this revision to Diff 36490.Jun 21 2018, 10:29 PM

len() of UTF-8 encoded bytearray is different than len(str).
Account for the difference when accumulating sizes.

Unicode Names are always ASCII, so here len(bytearray) == len(str), and no change needed.

This revision is now accepted and ready to land.Jun 21 2018, 10:29 PM
cfeck requested review of this revision.Jun 21 2018, 10:29 PM
lbeltrame requested changes to this revision.Jun 22 2018, 4:43 AM
lbeltrame added inline comments.
src/kcharselect-generate-datafile.py
41

Perhaps the diff view is wrong.. but the return size here (at this level of nesting) wouldn't make the downstream code de facto unreachable in this function?

118

Same here.

This revision now requires changes to proceed.Jun 22 2018, 4:43 AM
lbeltrame accepted this revision.Jun 22 2018, 4:50 AM

I did an accept to undo my earlier "Changes required" because Phab messed up the lines I commented on, and because I realized I wasn't commenting on your specific changes. Sorry about that.

src/kcharselect-generate-datafile.py
432

Perhaps the diff view is wrong.. but the return size here (at this level of nesting) wouldn't make the downstream code de facto unreachable in this function?

607

Unrelated to this patch, but this could be changed to for char in self.unihan (perhaps in a separate revision).

624

Same here wrt position of return. Now I notice that they're not related to your changes, so I wonder if it's phab showing something off, or there is a problem of tab vs spaces....

This revision is now accepted and ready to land.Jun 22 2018, 4:50 AM
This revision was automatically updated to reflect the committed changes.