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.
This commit is contained in:
José Matos 2024-06-18 10:25:52 +01:00
parent 5abe42f6d3
commit 44e0940d75
22 changed files with 147 additions and 147 deletions

View File

@ -19,21 +19,22 @@
"The LyX module has all the rules related with different lyx file formats." "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 gzip
import locale
import sys
import re
import time
import io
import codecs import codecs
import gzip
import io
import locale
import os.path
import re
import sys
import time
from parser_tools import (
check_token,
find_complete_lines,
find_end_of,
find_token,
get_value,
)
try: try:
import lyx2lyx_version import lyx2lyx_version

View File

@ -90,13 +90,14 @@ revert_language(document, lyxname, babelname="", polyglossianame=""):
""" """
import re import re
from parser_tools import ( from parser_tools import (
find_token,
find_end_of_inset, find_end_of_inset,
get_containing_layout, find_token,
get_containing_inset,
get_value,
get_bool_value, get_bool_value,
get_containing_inset,
get_containing_layout,
get_value,
) )
from unicode_symbols import unicode_reps from unicode_symbols import unicode_reps

View File

@ -18,7 +18,8 @@
"""Convert files to the file format generated by lyx 0.12""" """Convert files to the file format generated by lyx 0.12"""
import re 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): def space_before_layout(document):

View File

@ -18,7 +18,8 @@
"""Convert files to the file format generated by lyx 1.0""" """Convert files to the file format generated by lyx 1.0"""
import re import re
from parser_tools import find_token, find_re
from parser_tools import find_re, find_token
def obsolete_latex_title(document): def obsolete_latex_title(document):

View File

@ -18,7 +18,8 @@
"""Convert files to the file format generated by lyx 1.1.5""" """Convert files to the file format generated by lyx 1.1.5"""
import re 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 # Private helper functions

View File

@ -18,7 +18,8 @@
"""Convert files to the file format generated by lyx 1.1.6, until fix2""" """Convert files to the file format generated by lyx 1.1.6, until fix2"""
import re 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$") lyxtable_re = re.compile(r".*\\LyXTable$")

View File

@ -18,7 +18,8 @@
"""Convert files to the file format generated by lyx 1.1.6, fix3 and fix4""" """Convert files to the file format generated by lyx 1.1.6, fix3 and fix4"""
import re import re
from parser_tools import find_token, find_re
from parser_tools import find_re, find_token
def bool_table(item): def bool_table(item):

View File

@ -21,17 +21,17 @@
import re import re
from parser_tools import ( from parser_tools import (
check_token,
find_beginning_of,
find_end_of,
find_nonempty_line,
find_re,
find_token, find_token,
find_token_backwards, find_token_backwards,
find_tokens, find_tokens,
find_tokens_backwards, find_tokens_backwards,
find_beginning_of,
find_end_of,
find_re,
is_nonempty_line,
find_nonempty_line,
get_value, get_value,
check_token, is_nonempty_line,
) )
#################################################################### ####################################################################

View File

@ -19,7 +19,8 @@
"""Convert files to the file format generated by lyx 1.3""" """Convert files to the file format generated by lyx 1.3"""
import re 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 # Private helper functions

View File

@ -19,24 +19,24 @@
"""Convert files to the file format generated by lyx 1.4""" """Convert files to the file format generated by lyx 1.4"""
import re
from os import access, F_OK
import os.path import os.path
from parser_tools import ( import re
check_token, from os import F_OK, access
find_token,
get_value,
is_nonempty_line,
find_tokens,
find_end_of,
find_beginning_of,
find_token_exact,
find_tokens_exact,
find_re,
find_tokens_backwards,
)
from lyx_0_12 import update_latexaccents from lyx_0_12 import update_latexaccents
from parser_tools import (
check_token,
find_beginning_of,
find_end_of,
find_re,
find_token,
find_token_exact,
find_tokens,
find_tokens_backwards,
find_tokens_exact,
get_value,
is_nonempty_line,
)
#################################################################### ####################################################################
# Private helper functions # Private helper functions

View File

@ -18,24 +18,24 @@
"""Convert files to the file format generated by lyx 1.5""" """Convert files to the file format generated by lyx 1.5"""
import re
import unicodedata
import sys
import os import os
import re
import sys
import unicodedata
from LyX import get_encoding
from lyx2lyx_tools import insert_document_option
from parser_tools import ( from parser_tools import (
find_beginning_of,
find_end_of,
find_nonempty_line,
find_re, find_re,
find_token, find_token,
find_token_backwards, find_token_backwards,
find_token_exact, find_token_exact,
find_tokens, find_tokens,
find_end_of,
get_value, get_value,
find_beginning_of,
find_nonempty_line,
) )
from lyx2lyx_tools import insert_document_option
from LyX import get_encoding
#################################################################### ####################################################################
# Private helper functions # Private helper functions

View File

@ -19,7 +19,7 @@
import re 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 from unicode_symbols import unicode_reps
#################################################################### ####################################################################

View File

@ -19,33 +19,32 @@
import re 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 ( from lyx2lyx_tools import (
add_to_preamble, add_to_preamble,
hex2ratio,
insert_to_preamble, insert_to_preamble,
put_cmd_in_ert,
lyx2latex,
latex_length, latex_length,
lyx2latex,
put_cmd_in_ert,
revert_flex_inset, revert_flex_inset,
revert_font_attrs, revert_font_attrs,
hex2ratio,
str2bool,
revert_language, 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,
) )
#################################################################### ####################################################################

View File

@ -19,34 +19,32 @@
import re 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 ( from parser_tools import (
count_pars_in_inset, count_pars_in_inset,
del_complete_lines, del_complete_lines,
del_token, del_token,
find_token,
find_token_exact,
find_token_backwards,
find_end_of, find_end_of,
find_end_of_inset, find_end_of_inset,
find_end_of_layout, find_end_of_layout,
find_end_of_sequence, find_end_of_sequence,
find_re, find_re,
get_option_value, find_token,
get_containing_layout, find_token_backwards,
find_token_exact,
get_containing_inset, get_containing_inset,
get_value, get_containing_layout,
get_option_value,
get_quoted_value, get_quoted_value,
get_value,
set_option_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, \ # from lyx2lyx_tools import insert_to_preamble, \
# lyx2latex, latex_length, revert_flex_inset, \ # lyx2latex, latex_length, revert_flex_inset, \
# revert_font_attrs, hex2ratio, str2bool # revert_font_attrs, hex2ratio, str2bool

View File

@ -17,22 +17,20 @@
"""Convert files to the file format generated by lyx 2.2""" """Convert files to the file format generated by lyx 2.2"""
import re
import os import os
import re
# Uncomment only what you need to import, please. # Uncomment only what you need to import, please.
from lyx2lyx_tools import ( from lyx2lyx_tools import (
add_to_preamble, add_to_preamble,
put_cmd_in_ert, convert_info_insets,
get_ert, get_ert,
length_in_bp,
lyx2latex, lyx2latex,
lyx2verbatim, lyx2verbatim,
length_in_bp, put_cmd_in_ert,
convert_info_insets,
revert_language, revert_language,
) )
from parser_tools import ( from parser_tools import (
check_token, check_token,
del_complete_lines, del_complete_lines,
@ -43,15 +41,14 @@ from parser_tools import (
find_substring, find_substring,
find_token, find_token,
find_token_backwards, find_token_backwards,
get_containing_layout,
get_containing_inset, get_containing_inset,
get_containing_layout,
get_quoted_value, get_quoted_value,
get_value, get_value,
is_in_inset, is_in_inset,
set_bool_value, set_bool_value,
) )
#################################################################### ####################################################################
# Private helper functions # Private helper functions

View File

@ -19,40 +19,39 @@
import re 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 ( from parser_tools import (
del_complete_lines,
del_token, del_token,
del_value, del_value,
del_complete_lines,
find_complete_lines, find_complete_lines,
find_end_of_layout,
find_end_of_inset, find_end_of_inset,
find_end_of_layout,
find_re, find_re,
find_substring, find_substring,
find_token, find_token,
find_token_backwards, find_token_backwards,
get_bool_value,
get_containing_inset, get_containing_inset,
get_containing_layout, get_containing_layout,
get_bool_value,
get_value,
get_quoted_value, get_quoted_value,
get_value,
is_in_inset, is_in_inset,
set_bool_value, 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 # Private helper functions

View File

@ -18,9 +18,17 @@
"""Convert files to the file format generated by lyx 2.4""" """Convert files to the file format generated by lyx 2.4"""
import re 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 ( from parser_tools import (
count_pars_in_inset, count_pars_in_inset,
del_complete_lines, del_complete_lines,
@ -28,29 +36,19 @@ from parser_tools import (
find_end_of, find_end_of,
find_end_of_inset, find_end_of_inset,
find_end_of_layout, find_end_of_layout,
find_re,
find_token, find_token,
find_token_backwards, find_token_backwards,
find_token_exact, find_token_exact,
find_re,
get_bool_value, get_bool_value,
get_containing_inset, get_containing_inset,
get_containing_layout, get_containing_layout,
get_option_value, get_option_value,
get_value,
get_quoted_value, get_quoted_value,
get_value,
is_in_inset, 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 # Private helper functions

View File

@ -19,9 +19,6 @@
import re 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, # count_pars_in_inset, del_complete_lines, del_token, find_end_of,
# find_end_of_layout, # find_end_of_layout,
# find_token_backwards, find_token_exact, get_bool_value, # 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, # find_re, find_substring,
# set_bool_value # set_bool_value
# find_tokens, check_token # find_tokens, check_token
from lyx2lyx_tools import add_to_preamble, latex_length 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, # put_cmd_in_ert, insert_to_preamble, lyx2latex,
# revert_language, revert_flex_inset, str2bool, # revert_language, revert_flex_inset, str2bool,
# revert_font_attrs, # revert_font_attrs,

View File

@ -21,11 +21,11 @@ import imp
lyx2lyx = imp.load_source("lyx2lyx", "lyx2lyx", open("lyx2lyx")) lyx2lyx = imp.load_source("lyx2lyx", "lyx2lyx", open("lyx2lyx"))
# Profiler used in the study # Profiler used in the study
import os
import hotshot import hotshot
import hotshot.stats import hotshot.stats
import os
""" """
This program profiles lyx2lyx. This program profiles lyx2lyx.
Usage: Usage:

View File

@ -18,7 +18,8 @@
"This modules tests the auxiliary functions for lyx2lyx." "This modules tests the auxiliary functions for lyx2lyx."
import unittest 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): class TestParserTools(unittest.TestCase):

View File

@ -18,23 +18,23 @@
"This modules tests the functions used to help parse lines." "This modules tests the functions used to help parse lines."
import unittest import unittest
from parser_tools import ( from parser_tools import (
check_token, check_token,
is_nonempty_line,
find_token,
find_substring,
find_re,
re,
find_complete_lines,
find_across_lines,
find_tokens,
get_value,
get_bool_value,
del_complete_lines, del_complete_lines,
del_value, del_value,
set_bool_value find_across_lines,
) find_complete_lines,
find_re,
find_substring,
find_token,
find_tokens,
get_bool_value,
get_value,
is_nonempty_line,
re,
set_bool_value,
)
lines = r""" lines = r"""
\begin_layout Standard \begin_layout Standard

View File

@ -17,9 +17,9 @@
"Import unicode_reps from this module for access to the unicode<->LaTeX mapping." "Import unicode_reps from this module for access to the unicode<->LaTeX mapping."
import codecs
import os import os
import re import re
import codecs
def read_unicodesymbols(): def read_unicodesymbols():