Community
    • Login

    Config Files Need Updating, Too

    Scheduled Pinned Locked Moved General Discussion
    pythonscriptconfig-filesstylers.xmllangs.xmlsyntax highlight
    25 Posts 6 Posters 1.9k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • PeterJonesP
      PeterJones @Lycan Thrope
      last edited by

      @Lycan-Thrope said at various times:

      Hmm, I have both installed. 2.7 and 3.10.

      and

      I went back to 2.7 for the PythonScript plugin

      The way you’ve phrased things in this conversation, you seem to have mentally blurred the lines between the plugin version and the version of Python that the plugin uses.

      All that matters to the plugin is which version of the PythonScript plugin you use, and which python###.dll the plugin provides. It doesn’t matter which python.exe you might have installed elsewhere on your computer, whether they are Python 2.7 or Python 3.10 or anything else (and, in fact, the plugin ignores other installations unless you have checkmarked the ☑ Prefer installed Python libraries plugin option; and if you have that option checked, the installed version must match the 3.xx that PythonScript was compiled against).

      • PythonScript plugin v2.0.0.0 uses Python 2.7.
        • There is no plugin v2.7.
      • PythonScript plugin v3.0.xx uses Python 3.yy.
        • The plugin hasn’t gotten to v3.10 yet
        • It’s currently on PythonScript v3.0.18 using Python 3.12.3
        • you might want to give PythonScript v3.0.18 a try, because it seems pretty stable

      Both the plugin version and the python version are available in Plugins > PythonScript > About and printed to the console when you first open Plugins > PythonScript > Show Console

      Lycan ThropeL 1 Reply Last reply Reply Quote 2
      • EkopalypseE
        Ekopalypse
        last edited by

        Hello Peter,
        many thanks for the script.

        Two comments:

        a) Themes with commented LexerTypes cause an exception when sorting.

        Not really tested, but you could think about something like

                def sort_key(child):
                    child_name = child.get('name')
                    return (False, '') if child_name is None else (child_name == 'searchResult', child_name)
        
                elThemeLexerStyles[:] = sorted(elThemeLexerStyles, key=sort_key)
        

        b) Themes without top-level comments receive the comments from the previous theme. For example, I have a theme called mytheme.xml that now contains the copyright comments from mossylawn.xml.

        PeterJonesP 1 Reply Last reply Reply Quote 2
        • PeterJonesP
          PeterJones @Ekopalypse
          last edited by

          @Ekopalypse ,

          Thanks for those catches. v1.03 is now available at the permalink, and should fix both of those issues

          1 Reply Last reply Reply Quote 2
          • Lycan ThropeL
            Lycan Thrope @PeterJones
            last edited by

            @PeterJones ,
            The first is what mine shows.
            PythonScript plugin v2.0.0.0 uses Python 2.7.

            Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]
            Copyright (c) 2001-2020 Python Software Foundation.
            All Rights Reserved.
            

            I have Python27.dll in the C:\Program Files\Notepad++\plugins\PythonScript - directory.
            And, I didn’t have the Prefer option checked, in the Options menu.
            Just for confirmation.

            1 Reply Last reply Reply Quote 0
            • PeterJonesP PeterJones referenced this topic on
            • PeterJonesP
              PeterJones
              last edited by PeterJones

              v1.06 is available from the permalink:

              • v1.05 (2024-Sep-05): Add URLs to source code, so you remember where to get an updated copy. (was not announced, since it was not a critical feature/bugfix upgrade)
              • v1.06 (2024-Sep-14): IMPROVEMENT = error handling for <installed>\themes\ permissions
                • The most common error is that you don’t have write permissions for the default themes, which are installed in the installation directory instead of your AppData or other config directory.
                • Users have been confused when it doesn’t complete because of write permissions, because I forgot that not everyone has PythonScript set to show the Console if there’s an error, and that error isn’t intuitive to the general audience even if they look in the Console.
                • I now trap that error, and I’ve added a MessageBox to inform you of the error, letting you know that if you re-run Notepad++ As Admin, then it should work.
                  • Some users have found that when they run As Admin, PythonScript no longer sees their user scripts from the AppData hierarchy. If that’s the case, just save another copy of the script in the Machine Scripts section while you’re running As Admin.
                • Even if you get the write error on the <installed>\themes, your AppData or other config-directory stylers and themes and langs.xml should all be properly updated. (If you use Windows Explorer, you should be able to see the last-modified time on the AppData or other config-directory files has been updated after running the script.)
              1 Reply Last reply Reply Quote 2
              • PeterJonesP
                PeterJones
                last edited by

                v1.07 is available from the permalink:

                • fix global styles
                  1. copy global-styles colors from stylers.model.xml to stylers.xml (similar to what’s already done on stylers.xml’s lexer-styles)
                  2. when updating/adding global styles in either stylers.xml or themes\*.xml, make sure global-styles don’t have extra attributes that confuse the StyleConfigurator interface

                running v1.07 will clean up the Global Styles attributes to match the stylers.model.xml, even if you’ve run a previous version of the script

                1 Reply Last reply Reply Quote 5
                • notdodgeballN
                  notdodgeball
                  last edited by

                  @PeterJones, I used version 1.07 of the script and the copyright information on top got removed from the theme files.

                  They were also unmodified, straight from the install directories, version Portable v8.7.1

                  PeterJonesP 1 Reply Last reply Reply Quote 0
                  • PeterJonesP
                    PeterJones @notdodgeball
                    last edited by

                    @notdodgeball ,

                    Apparently the xml.etree library behaves differently between Python 2.7 and 3.12 (used by PS2 and PS3 respectively).

                    I really wish PS3 would move out of alpha and release into Plugins Admin, so that we could just stick with PythonScript 3 for sharing scripts in the forum, and not have to contend with all the headaches of keeping scripts compatible with two major versions of Python, and all the library differences that come with that.

                    (it also would’ve been nice if Don hadn’t allowed theme authors to submit themes with XML that have invalid top-level comments, which the XML parsing engines don’t like because it’s not valid XML)

                    v1.08 is available from the permalink, fixing the handling of the invalid XML in PythonScript 2.

                    However, I highly recommend making the switch to PythonScript 3, despite it claiming to be alpha, unless you are using a lot of ANSI characterset files rather than real unicode-based encodings. I don’t know how much longer I’ll support PythonScript 2 for this script.

                    1 Reply Last reply Reply Quote 4
                    • PeterJonesP PeterJones referenced this topic on
                    • PeterJonesP
                      PeterJones
                      last edited by PeterJones

                      ConfigUpdater v1.99_beta1 – Plugin Version

                      Initial Beta Testing Wanted

                      I have what I believe to be a working ConfigUpdater Plugin which implements the same functionality as the ConfigUpdater.py script, but without requiring the PythonScript plugin (which is a huge overhead for many normal users).

                      For the next few days, you can download the ConfigUpdater.dll from the Artifacts listed in this GitHub build of v1.99_beta1

                      If, like @Alan-Kilborn, you like having a copy of the “intermediate sorted” files (which don’t include any of the “updates” that the plugin grabs from the model files, but are sorted in the same order as will be in the final version of each config file, for easier comparison of what changed), then create ...\plugins\Config\ConfigUpdaterSettings.xml before running this plugin, with the contents:

                      <ConfigUpdaterSettings>
                          <Setting name="DEBUG" isIntermediateSorted="1"/>
                      </ConfigUpdaterSettings>
                      

                      If it needs Elevated UAC permissions, it will ask you, and restart Notepad++: if it restarts, you will have to run the plugin command again after Notepad++ is ready. (It will also ask, once done, if you want to go back to non-Elevated mode, because running AsAdmin is a bad idea. ;-) )

                      For beta testing, it’s probably a good idea to keep a copy of your original langs.xml/stylers.xml/theme files

                      Everything else should hopefully be self-explanatory.

                      Please let me know if you have problems (or if everything works great).

                      PeterJonesP 1 Reply Last reply Reply Quote 5
                      • PeterJonesP
                        PeterJones @PeterJones
                        last edited by

                        @PeterJones said in Config Files Need Updating, Too:

                        Please let me know if you have problems (or if everything works great).

                        A lot of upvotes, but no comments. Must not have any bugs. :-)

                        Since that post, I did a few micro updates, including improved About box, and better automation of the zipfile when I create a tag.

                        For beta5, I added one last feature: even on portable, where you don’t need elevated permission, when it finishes the updates, it will ask if you want to restart Notepad++ (since changes won’t take effect until a restart)

                        If anyone was interested in testing, the v1.99_beta5 is available at https://github.com/pryrt/NppPlugin-ConfigUpdater/releases/tag/v1.99_beta5

                        I am planning on submitting v2.0 to the nppPluginList repo this weekend.

                        PeterJonesP Lycan ThropeL 2 Replies Last reply Reply Quote 0
                        • PeterJonesP
                          PeterJones @PeterJones
                          last edited by

                          v1.99_beta6 = BugFix: better error handling if langs.xml or a stylers/themes XML file has invalid XML – under many circumstances, it will tell you there’s an error, then open the offending file and embed a scintilla Annotation on the appropriate line number. (If it cannot figure out a line number, it will just do a MessageBox with the error, and then stop processing that file.)

                          (Thanks to @Ekopalypse for catching the problem.)

                          1 Reply Last reply Reply Quote 2
                          • Lycan ThropeL
                            Lycan Thrope @PeterJones
                            last edited by Lycan Thrope

                            @PeterJones said in Config Files Need Updating, Too:

                            A lot of upvotes, but no comments. Must not have any bugs. :-)

                            Haven’t had a chance to test it yet, so not sure if that’s true. :-)

                            Update: I’ve posted my Debug info and a screenshot of what I see on a Standard install to the Github page. No request to shutdown, it just shuts down after a while of looking at the spinning wheel, and then crash closes as far as I can tell.

                            The portable install worked fine from what I can see. It has the same ConfigUpdaterSettings.xml file settings as the one in the AppData for the standard install, but the log for the standard install is empty. The portable one has a log of the changes made.

                            Not sure what happened. I did initially install it to the wrong location, putting it in the Appdata directory, but it didn’t show in plugins so did not run. I then cut and copied the entire folder to the Programs folder location and it showed in the Standard install Plugins, I ran it, and the same things happened when I ran it for the first time, and everytime I run it again…consistent.

                            If it doesn’t change anything being as it’s the latest version of NPP, shouldn’t it not shutdown after running it with no changes?

                            PeterJonesP 1 Reply Last reply Reply Quote 0
                            • PeterJonesP
                              PeterJones @Lycan Thrope
                              last edited by

                              @Lycan-Thrope ,

                              As I say in my reply over there, it looks like your copy is getting stuck long before it would ask to restart – it should have printed at least stylers.xml in the Status dialog. When I use my Win11 installed v8.8.1, or spin up a Win10 VM with an installed v8.8.1, it works as expected for me, so I don’t know what’s happening for you. We can continue the debug over in your Issue #2 discussion.

                              If it doesn’t change anything being as it’s the latest version of NPP, shouldn’t it not shutdown after running it with no changes?

                              haha, you’re funny. The “latest version of NPP” ships with themes that have many missing LexerTypes (languages) and stylers within the lexers, which is a major reason this plugin is needed. If you’ve never run the old ConfigUpdater.py or the plugin version, it’s guaranteed to make changes. (And even if you have run it before, because it does things like sort the languages, it always attempts to write all the themes, so will ask to restart even if it’s writing the same values back – someday, I might get my logic better to figure out how to compare the old-vs-new for the XML, and not ask to write if it doesn’t need to; but for now, that was the easiest to program.)

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              The Community of users of the Notepad++ text editor.
                              Powered by NodeBB | Contributors