commit 44e0940d7575d59de728e7b4c30f06374711fcba
Author: José Matos <jama...@lyx.org>
Date:   Tue Jun 18 10:25:52 2024 +0100

    Order imports
    
    This is similar to what we have in C++ code where we order the standard
    includes to be easier to read.
    
    This is a readability change only.
---
 lib/lyx2lyx/LyX.py                | 23 ++++++++++++-----------
 lib/lyx2lyx/lyx2lyx_tools.py      |  7 ++++---
 lib/lyx2lyx/lyx_0_12.py           |  3 ++-
 lib/lyx2lyx/lyx_1_0.py            |  3 ++-
 lib/lyx2lyx/lyx_1_1_5.py          |  3 ++-
 lib/lyx2lyx/lyx_1_1_6_0.py        |  3 ++-
 lib/lyx2lyx/lyx_1_1_6_3.py        |  3 ++-
 lib/lyx2lyx/lyx_1_2.py            | 12 ++++++------
 lib/lyx2lyx/lyx_1_3.py            |  3 ++-
 lib/lyx2lyx/lyx_1_4.py            | 22 +++++++++++-----------
 lib/lyx2lyx/lyx_1_5.py            | 14 +++++++-------
 lib/lyx2lyx/lyx_1_6.py            |  2 +-
 lib/lyx2lyx/lyx_2_0.py            | 39 +++++++++++++++++++--------------------
 lib/lyx2lyx/lyx_2_1.py            | 24 +++++++++++-------------
 lib/lyx2lyx/lyx_2_2.py            | 13 +++++--------
 lib/lyx2lyx/lyx_2_3.py            | 33 ++++++++++++++++-----------------
 lib/lyx2lyx/lyx_2_4.py            | 26 ++++++++++++--------------
 lib/lyx2lyx/lyx_2_5.py            |  8 ++++----
 lib/lyx2lyx/profiling.py          |  4 ++--
 lib/lyx2lyx/test_lyx2lyx_tools.py |  3 ++-
 lib/lyx2lyx/test_parser_tools.py  | 24 ++++++++++++------------
 lib/lyx2lyx/unicode_symbols.py    |  2 +-
 22 files changed, 137 insertions(+), 137 deletions(-)

diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index 751a7b5f4b..ff0e18813c 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -19,21 +19,22 @@
 
 "The LyX module has all the rules related with different lyx file formats."
 
-from parser_tools import (
-    get_value,
-    check_token,
-    find_token,
-    find_end_of,
-    find_complete_lines,
-)
-import os.path
+import codecs
 import gzip
+import io
 import locale
-import sys
+import os.path
 import re
+import sys
 import time
-import io
-import codecs
+
+from parser_tools import (
+    check_token,
+    find_complete_lines,
+    find_end_of,
+    find_token,
+    get_value,
+)
 
 try:
     import lyx2lyx_version
diff --git a/lib/lyx2lyx/lyx2lyx_tools.py b/lib/lyx2lyx/lyx2lyx_tools.py
index 706c808fc6..9d713609d7 100644
--- a/lib/lyx2lyx/lyx2lyx_tools.py
+++ b/lib/lyx2lyx/lyx2lyx_tools.py
@@ -90,13 +90,14 @@ revert_language(document, lyxname, babelname="", 
polyglossianame=""):
 """
 
 import re
+
 from parser_tools import (
-    find_token,
     find_end_of_inset,
-    get_containing_layout,
+    find_token,
+    get_bool_value,
     get_containing_inset,
+    get_containing_layout,
     get_value,
-    get_bool_value,
 )
 from unicode_symbols import unicode_reps
 
diff --git a/lib/lyx2lyx/lyx_0_12.py b/lib/lyx2lyx/lyx_0_12.py
index 50405213ab..a3f19c8de6 100644
--- a/lib/lyx2lyx/lyx_0_12.py
+++ b/lib/lyx2lyx/lyx_0_12.py
@@ -18,7 +18,8 @@
 """Convert files to the file format generated by lyx 0.12"""
 
 import re
-from parser_tools import find_token, find_re, check_token
+
+from parser_tools import check_token, find_re, find_token
 
 
 def space_before_layout(document):
diff --git a/lib/lyx2lyx/lyx_1_0.py b/lib/lyx2lyx/lyx_1_0.py
index 46cf16fbc1..c350698d2f 100644
--- a/lib/lyx2lyx/lyx_1_0.py
+++ b/lib/lyx2lyx/lyx_1_0.py
@@ -18,7 +18,8 @@
 """Convert files to the file format generated by lyx 1.0"""
 
 import re
-from parser_tools import find_token, find_re
+
+from parser_tools import find_re, find_token
 
 
 def obsolete_latex_title(document):
diff --git a/lib/lyx2lyx/lyx_1_1_5.py b/lib/lyx2lyx/lyx_1_1_5.py
index b8cf734f09..203cb055ba 100644
--- a/lib/lyx2lyx/lyx_1_1_5.py
+++ b/lib/lyx2lyx/lyx_1_1_5.py
@@ -18,7 +18,8 @@
 """Convert files to the file format generated by lyx 1.1.5"""
 
 import re
-from parser_tools import find_token, find_token_backwards, find_re
+
+from parser_tools import find_re, find_token, find_token_backwards
 
 ####################################################################
 # Private helper functions
diff --git a/lib/lyx2lyx/lyx_1_1_6_0.py b/lib/lyx2lyx/lyx_1_1_6_0.py
index 635056215a..f117240c46 100644
--- a/lib/lyx2lyx/lyx_1_1_6_0.py
+++ b/lib/lyx2lyx/lyx_1_1_6_0.py
@@ -18,7 +18,8 @@
 """Convert files to the file format generated by lyx 1.1.6, until fix2"""
 
 import re
-from parser_tools import find_re, find_tokens, find_token, check_token
+
+from parser_tools import check_token, find_re, find_token, find_tokens
 
 lyxtable_re = re.compile(r".*\\LyXTable$")
 
diff --git a/lib/lyx2lyx/lyx_1_1_6_3.py b/lib/lyx2lyx/lyx_1_1_6_3.py
index 390d7345fe..2e7faabe5b 100644
--- a/lib/lyx2lyx/lyx_1_1_6_3.py
+++ b/lib/lyx2lyx/lyx_1_1_6_3.py
@@ -18,7 +18,8 @@
 """Convert files to the file format generated by lyx 1.1.6, fix3 and fix4"""
 
 import re
-from parser_tools import find_token, find_re
+
+from parser_tools import find_re, find_token
 
 
 def bool_table(item):
diff --git a/lib/lyx2lyx/lyx_1_2.py b/lib/lyx2lyx/lyx_1_2.py
index 8fd4f3592d..d779a4b86e 100644
--- a/lib/lyx2lyx/lyx_1_2.py
+++ b/lib/lyx2lyx/lyx_1_2.py
@@ -21,17 +21,17 @@
 import re
 
 from parser_tools import (
+    check_token,
+    find_beginning_of,
+    find_end_of,
+    find_nonempty_line,
+    find_re,
     find_token,
     find_token_backwards,
     find_tokens,
     find_tokens_backwards,
-    find_beginning_of,
-    find_end_of,
-    find_re,
-    is_nonempty_line,
-    find_nonempty_line,
     get_value,
-    check_token,
+    is_nonempty_line,
 )
 
 ####################################################################
diff --git a/lib/lyx2lyx/lyx_1_3.py b/lib/lyx2lyx/lyx_1_3.py
index 6fece5c01c..0e1decb97e 100644
--- a/lib/lyx2lyx/lyx_1_3.py
+++ b/lib/lyx2lyx/lyx_1_3.py
@@ -19,7 +19,8 @@
 """Convert files to the file format generated by lyx 1.3"""
 
 import re
-from parser_tools import find_token, find_end_of, get_value, find_token_exact
+
+from parser_tools import find_end_of, find_token, find_token_exact, get_value
 
 ####################################################################
 # Private helper functions
diff --git a/lib/lyx2lyx/lyx_1_4.py b/lib/lyx2lyx/lyx_1_4.py
index 58b59bb5c2..d6cea72929 100644
--- a/lib/lyx2lyx/lyx_1_4.py
+++ b/lib/lyx2lyx/lyx_1_4.py
@@ -19,25 +19,25 @@
 
 """Convert files to the file format generated by lyx 1.4"""
 
-import re
-from os import access, F_OK
 import os.path
+import re
+from os import F_OK, access
+
+from lyx_0_12 import update_latexaccents
 from parser_tools import (
     check_token,
-    find_token,
-    get_value,
-    is_nonempty_line,
-    find_tokens,
-    find_end_of,
     find_beginning_of,
-    find_token_exact,
-    find_tokens_exact,
+    find_end_of,
     find_re,
+    find_token,
+    find_token_exact,
+    find_tokens,
     find_tokens_backwards,
+    find_tokens_exact,
+    get_value,
+    is_nonempty_line,
 )
 
-from lyx_0_12 import update_latexaccents
-
 ####################################################################
 # Private helper functions
 
diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py
index 8dad1db11e..eddca0ada3 100644
--- a/lib/lyx2lyx/lyx_1_5.py
+++ b/lib/lyx2lyx/lyx_1_5.py
@@ -18,24 +18,24 @@
 
 """Convert files to the file format generated by lyx 1.5"""
 
+import os
 import re
-import unicodedata
 import sys
-import os
+import unicodedata
 
+from LyX import get_encoding
+from lyx2lyx_tools import insert_document_option
 from parser_tools import (
+    find_beginning_of,
+    find_end_of,
+    find_nonempty_line,
     find_re,
     find_token,
     find_token_backwards,
     find_token_exact,
     find_tokens,
-    find_end_of,
     get_value,
-    find_beginning_of,
-    find_nonempty_line,
 )
-from lyx2lyx_tools import insert_document_option
-from LyX import get_encoding
 
 ####################################################################
 # Private helper functions
diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py
index 92cfdc34b0..f63333dc25 100644
--- a/lib/lyx2lyx/lyx_1_6.py
+++ b/lib/lyx2lyx/lyx_1_6.py
@@ -19,7 +19,7 @@
 
 import re
 
-from parser_tools import find_token, find_end_of, find_tokens, get_value
+from parser_tools import find_end_of, find_token, find_tokens, get_value
 from unicode_symbols import unicode_reps
 
 ####################################################################
diff --git a/lib/lyx2lyx/lyx_2_0.py b/lib/lyx2lyx/lyx_2_0.py
index 5dfc348176..ac16cf3124 100644
--- a/lib/lyx2lyx/lyx_2_0.py
+++ b/lib/lyx2lyx/lyx_2_0.py
@@ -19,33 +19,32 @@
 
 import re
 
-from parser_tools import (
-    del_complete_lines,
-    find_token,
-    find_end_of,
-    find_token_exact,
-    find_end_of_inset,
-    find_end_of_layout,
-    find_token_backwards,
-    is_in_inset,
-    get_value,
-    get_quoted_value,
-    del_token,
-    check_token,
-    get_option_value,
-)
-
 from lyx2lyx_tools import (
     add_to_preamble,
+    hex2ratio,
     insert_to_preamble,
-    put_cmd_in_ert,
-    lyx2latex,
     latex_length,
+    lyx2latex,
+    put_cmd_in_ert,
     revert_flex_inset,
     revert_font_attrs,
-    hex2ratio,
-    str2bool,
     revert_language,
+    str2bool,
+)
+from parser_tools import (
+    check_token,
+    del_complete_lines,
+    del_token,
+    find_end_of,
+    find_end_of_inset,
+    find_end_of_layout,
+    find_token,
+    find_token_backwards,
+    find_token_exact,
+    get_option_value,
+    get_quoted_value,
+    get_value,
+    is_in_inset,
 )
 
 ####################################################################
diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py
index 503507a0e0..3155cc2489 100644
--- a/lib/lyx2lyx/lyx_2_1.py
+++ b/lib/lyx2lyx/lyx_2_1.py
@@ -19,34 +19,32 @@
 
 import re
 
-# Uncomment only what you need to import, please.
+# from parser_tools import find_token, find_end_of, find_tokens, \
+# find_end_of_inset, find_end_of_layout, \
+# is_in_inset, del_token, check_token
+from lyx2lyx_tools import add_to_preamble, get_ert, put_cmd_in_ert, 
revert_language
 
+# Uncomment only what you need to import, please.
 from parser_tools import (
     count_pars_in_inset,
     del_complete_lines,
     del_token,
-    find_token,
-    find_token_exact,
-    find_token_backwards,
     find_end_of,
     find_end_of_inset,
     find_end_of_layout,
     find_end_of_sequence,
     find_re,
-    get_option_value,
-    get_containing_layout,
+    find_token,
+    find_token_backwards,
+    find_token_exact,
     get_containing_inset,
-    get_value,
+    get_containing_layout,
+    get_option_value,
     get_quoted_value,
+    get_value,
     set_option_value,
 )
 
-# from parser_tools import find_token, find_end_of, find_tokens, \
-# find_end_of_inset, find_end_of_layout, \
-# is_in_inset, del_token, check_token
-
-from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, 
revert_language
-
 # from lyx2lyx_tools import insert_to_preamble, \
 #  lyx2latex, latex_length, revert_flex_inset, \
 #  revert_font_attrs, hex2ratio, str2bool
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index 30aafb7789..aa3ceb1a75 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -17,22 +17,20 @@
 
 """Convert files to the file format generated by lyx 2.2"""
 
-import re
 import os
+import re
 
 # Uncomment only what you need to import, please.
-
 from lyx2lyx_tools import (
     add_to_preamble,
-    put_cmd_in_ert,
+    convert_info_insets,
     get_ert,
+    length_in_bp,
     lyx2latex,
     lyx2verbatim,
-    length_in_bp,
-    convert_info_insets,
+    put_cmd_in_ert,
     revert_language,
 )
-
 from parser_tools import (
     check_token,
     del_complete_lines,
@@ -43,15 +41,14 @@ from parser_tools import (
     find_substring,
     find_token,
     find_token_backwards,
-    get_containing_layout,
     get_containing_inset,
+    get_containing_layout,
     get_quoted_value,
     get_value,
     is_in_inset,
     set_bool_value,
 )
 
-
 ####################################################################
 # Private helper functions
 
diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py
index fe609841fb..c0cfcaac20 100644
--- a/lib/lyx2lyx/lyx_2_3.py
+++ b/lib/lyx2lyx/lyx_2_3.py
@@ -19,40 +19,39 @@
 
 import re
 
-# Uncomment only what you need to import, please.
+from lyx2lyx_tools import (
+    add_to_preamble,
+    insert_document_option,
+    insert_to_preamble,
+    is_document_option,
+    latex_length,
+    put_cmd_in_ert,
+    remove_document_option,
+    revert_font_attrs,
+    revert_language,
+)
 
+# Uncomment only what you need to import, please.
 from parser_tools import (
+    del_complete_lines,
     del_token,
     del_value,
-    del_complete_lines,
     find_complete_lines,
-    find_end_of_layout,
     find_end_of_inset,
+    find_end_of_layout,
     find_re,
     find_substring,
     find_token,
     find_token_backwards,
+    get_bool_value,
     get_containing_inset,
     get_containing_layout,
-    get_bool_value,
-    get_value,
     get_quoted_value,
+    get_value,
     is_in_inset,
     set_bool_value,
 )
 
-from lyx2lyx_tools import (
-    add_to_preamble,
-    put_cmd_in_ert,
-    revert_font_attrs,
-    insert_to_preamble,
-    latex_length,
-    is_document_option,
-    insert_document_option,
-    remove_document_option,
-    revert_language,
-)
-
 ####################################################################
 # Private helper functions
 
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index e846c01c37..e807cc4c28 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -18,9 +18,17 @@
 """Convert files to the file format generated by lyx 2.4"""
 
 import re
+from datetime import date, datetime, time
 
-from datetime import datetime, date, time
-
+from lyx2lyx_tools import (
+    add_to_preamble,
+    insert_to_preamble,
+    lyx2latex,
+    put_cmd_in_ert,
+    revert_flex_inset,
+    revert_language,
+    str2bool,
+)
 from parser_tools import (
     count_pars_in_inset,
     del_complete_lines,
@@ -28,29 +36,19 @@ from parser_tools import (
     find_end_of,
     find_end_of_inset,
     find_end_of_layout,
+    find_re,
     find_token,
     find_token_backwards,
     find_token_exact,
-    find_re,
     get_bool_value,
     get_containing_inset,
     get_containing_layout,
     get_option_value,
-    get_value,
     get_quoted_value,
+    get_value,
     is_in_inset,
 )
 
-from lyx2lyx_tools import (
-    add_to_preamble,
-    insert_to_preamble,
-    lyx2latex,
-    put_cmd_in_ert,
-    revert_language,
-    revert_flex_inset,
-    str2bool,
-)
-
 ####################################################################
 # Private helper functions
 
diff --git a/lib/lyx2lyx/lyx_2_5.py b/lib/lyx2lyx/lyx_2_5.py
index 79f258eb14..6a96326e24 100644
--- a/lib/lyx2lyx/lyx_2_5.py
+++ b/lib/lyx2lyx/lyx_2_5.py
@@ -19,9 +19,6 @@
 
 import re
 
-# Uncomment only what you need to import, please.
-
-from parser_tools import find_end_of_inset, find_token, find_re, get_value
 #    count_pars_in_inset, del_complete_lines, del_token, find_end_of,
 #    find_end_of_layout,
 #    find_token_backwards, find_token_exact, get_bool_value,
@@ -32,8 +29,11 @@ from parser_tools import find_end_of_inset, find_token, 
find_re, get_value
 #    find_re, find_substring,
 #    set_bool_value
 #    find_tokens, check_token
-
 from lyx2lyx_tools import add_to_preamble, latex_length
+
+# Uncomment only what you need to import, please.
+from parser_tools import find_end_of_inset, find_re, find_token, get_value
+
 #  put_cmd_in_ert, insert_to_preamble, lyx2latex,
 #  revert_language, revert_flex_inset, str2bool,
 #  revert_font_attrs,
diff --git a/lib/lyx2lyx/profiling.py b/lib/lyx2lyx/profiling.py
index 97706d52aa..e947cfd602 100755
--- a/lib/lyx2lyx/profiling.py
+++ b/lib/lyx2lyx/profiling.py
@@ -21,11 +21,11 @@ import imp
 lyx2lyx = imp.load_source("lyx2lyx", "lyx2lyx", open("lyx2lyx"))
 
 # Profiler used in the study
+import os
+
 import hotshot
 import hotshot.stats
 
-import os
-
 """
 This program profiles lyx2lyx.
 Usage:
diff --git a/lib/lyx2lyx/test_lyx2lyx_tools.py 
b/lib/lyx2lyx/test_lyx2lyx_tools.py
index 4184b0e563..27d7097f93 100644
--- a/lib/lyx2lyx/test_lyx2lyx_tools.py
+++ b/lib/lyx2lyx/test_lyx2lyx_tools.py
@@ -18,7 +18,8 @@
 "This modules tests the auxiliary functions for lyx2lyx."
 
 import unittest
-from lyx2lyx_tools import put_cmd_in_ert, latex_length
+
+from lyx2lyx_tools import latex_length, put_cmd_in_ert
 
 
 class TestParserTools(unittest.TestCase):
diff --git a/lib/lyx2lyx/test_parser_tools.py b/lib/lyx2lyx/test_parser_tools.py
index f9bdc33d35..fa00da2b8a 100644
--- a/lib/lyx2lyx/test_parser_tools.py
+++ b/lib/lyx2lyx/test_parser_tools.py
@@ -18,23 +18,23 @@
 "This modules tests the functions used to help parse lines."
 
 import unittest
+
 from parser_tools import (
     check_token,
-    is_nonempty_line,
-    find_token,
-    find_substring,
-    find_re,
-    re,
-    find_complete_lines,
+    del_complete_lines,
+    del_value,
     find_across_lines,
+    find_complete_lines,
+    find_re,
+    find_substring,
+    find_token,
     find_tokens,
-    get_value,
     get_bool_value,
-    del_complete_lines,
-    del_value,
-    set_bool_value
-    )
-
+    get_value,
+    is_nonempty_line,
+    re,
+    set_bool_value,
+)
 
 lines = r"""
 \begin_layout Standard
diff --git a/lib/lyx2lyx/unicode_symbols.py b/lib/lyx2lyx/unicode_symbols.py
index d6f998e2f4..a41b48d1f2 100644
--- a/lib/lyx2lyx/unicode_symbols.py
+++ b/lib/lyx2lyx/unicode_symbols.py
@@ -17,9 +17,9 @@
 
 "Import unicode_reps from this module for access to the unicode<->LaTeX 
mapping."
 
+import codecs
 import os
 import re
-import codecs
 
 
 def read_unicodesymbols():
-- 
lyx-cvs mailing list
lyx-cvs@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-cvs

Reply via email to