Community
    • Login

    Config Files Need Updating, Too

    Scheduled Pinned Locked Moved General Discussion
    pythonscriptconfig-filesstylers.xmllangs.xmlsyntax highlight
    21 Posts 6 Posters 1.6k 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.
    • dinkumoilD
      dinkumoil @PeterJones
      last edited by dinkumoil

      @PeterJones said in Config Files Need Updating, Too:

      I have updated the script to hardcode the double-quotes for xml declaration/prolog.

      Thank you for the fix, works as expected.

      However, you might want to put in an issue at XML Tools …

      You are right, I will do that. [EDIT] Done [/EDIT]

      @Lycan-Thrope @PeterJones
      I use Notepad++ v8.6.9 (64 Bit), PythonScript v3.0.18 and XML Tools v3.1.1.13

      @Snabel42
      I’m not sure, but it seems like the engine setting you mentioned above only affects the formatting during pretty-printing. However, I use QuickXML.

      1 Reply Last reply Reply Quote 5
      • Lycan ThropeL
        Lycan Thrope @Snabel42
        last edited by

        @Snabel42 ,
        Apparently mine is QuickXML. I didn’t set anything, so it looks like it was preset for me.

        1 Reply Last reply Reply Quote 0
        • Lycan ThropeL
          Lycan Thrope
          last edited by Lycan Thrope

          @dinkumoil said in Config Files Need Updating, Too:

          I use Notepad++ v8.6.9 (64 Bit), PythonScript v3.0.18 and XML Tools v3.1.1.13

          That would explain the difference. I can’t remember exactly what the problem was or why I went back to 2.7 for the PythonScript plugin, but I just did…it might have been an early version where there were problems and I just stayed with the tried and true, at the time.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • 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).

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