Commit Graph

26 Commits

Author SHA1 Message Date
José Matos
44e0940d75 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.
2024-06-18 10:25:52 +01:00
José Matos
b4db3ea137 Reformat lyx2lyx code using ruff 2024-06-15 10:06:06 +01:00
José Matos
f9ec4186d7 Update lyx2lyx folder to Python 3+
Remove support for Python 2
Take advantage of new features (euphemism) not possible before due to
python 2 compatibility
2024-06-10 10:55:40 +01:00
Scott Kostyshak
677dc3b7a6 Python fixes from José Matos
See here:

  https://www.mail-archive.com/search?l=mid&q=a7960223ee91696e916b281d1d9fc55df10a9480.camel%40gmail.com

Description from José pasted below:

  Functions `length_in_bp` and `revert_flex_inset` have an error in a
  (almost) never used path. The reason why this was never triggered is
  because this is part of the code where we try all the best efforts
  to recover from an ill-formed LyX file.

  The problem is that the functions call the `document` variable to
  issue an warning if the file does not follow the usual structure.
  The simple fix is to add that variable (as the first for the
  functions) and to add them at all the places where the functions are
  called.

  For reference this code was introduced by Georg (Baum) more than 8
  years ago and it was never reported. So the issue is not urgent in
  any meaningful way. :-)

  In `lyx2lyx/lyx_2_0.py`, in the function `revert_nameref`, there is
  a call to the document variable. The same as all the above.

  In `lyx2lyx/lyx_2_4.py`, in the `class fontmapping`. Similar to the
  above but now for error.
2023-08-19 22:08:08 -04:00
Pavel Sanda
d79637a88e Various python fixes suggested by pyupgrade.
Patch from Jose.
https://www.mail-archive.com/lyx-devel@lists.lyx.org/msg217770.html
2022-07-31 00:36:51 +02:00
Richard Heck
1db883e183 In lib/lyx2lyx/: s/while 1/while True/ 2016-06-25 17:38:06 -04:00
Georg Baum
e93013057f Add missing backslashes
Found by 2to3, but useful for python2 as well for consistency reasons.
2016-06-08 22:17:14 +02:00
José Matos
9a0d70a45f First step to make lyx2lyx code support both python 2 and python 3 (3.3+)
Most of the changes are related with dictionaries returning views instead of
lists.

xrange -> range (since xrange is gone in python 3)

The code that is special to support both python 2 and 3 is enclosed in a comment
 \# Provide support for both python 2 and 3
and
 \# End of code to support for both python 2 and 3

And so later it can be removed safely when python 2 is no longer supported.
2015-03-11 12:09:18 +00:00
Pavel Sanda
aef6b16811 Update FSF address, patch from cornelisbb, #7735.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39523 a592a061-630c-0410-9148-cb99ea01b6c8
2011-08-25 23:10:36 +00:00
José Matox
26c0f379c7 Remove calls to deprecated module string.
The calls are now made to string methods, the advantage being that they work with
unicode strings.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14537 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-02 15:45:44 +00:00
José Matox
b00206e882 Small fixes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14535 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-02 14:23:45 +00:00
José Matox
695bfd88ed Convert all python files to utf-8.
Add a documentation string to each module.

Add a documentation string to every function in the modules.

file is a python reserved word => s/file/document/g as variable

add a new property to modules, supported_versions that holds
 the versions supported by that module

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14534 a592a061-630c-0410-9148-cb99ea01b6c8
2006-08-02 14:19:22 +00:00
José Matox
8fc2c1dd05 * LyX.py
* lyx_1_1_5.py
	* lyx_1_2.py
	* lyx_1_3.py
	* lyx_1_4.py
	* lyx_1_5.py

	* parser_tools.py: remove functions that are not generic, i.e.
assume a specific pattern for the file format, and move them to the
places where they are used.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14503 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-27 18:30:13 +00:00
Bo Peng
34001ec175 Remove all tabs in lib/lyx2lyx/*.py, corresponding to the added -tt option
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14285 a592a061-630c-0410-9148-cb99ea01b6c8
2006-07-01 19:16:09 +00:00
Georg Baum
b8227ebda0 fix bug 2026 and bug 2088
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13226 a592a061-630c-0410-9148-cb99ea01b6c8
2006-02-13 07:48:26 +00:00
Georg Baum
53a118caea fix bug 2031 (\lyxline conversion)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10466 a592a061-630c-0410-9148-cb99ea01b6c8
2005-09-20 12:47:45 +00:00
José Matox
7bd4678da5 Separate preamble from from header. Make its treatment more robust.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10398 a592a061-630c-0410-9148-cb99ea01b6c8
2005-08-18 17:33:26 +00:00
Angus Leeming
70572847e2 Whitespace, only whitespace. s/ +$//
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10024 a592a061-630c-0410-9148-cb99ea01b6c8
2005-06-09 09:58:08 +00:00
Georg Baum
3a4be311e6 repair tabular conversions
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9647 a592a061-630c-0410-9148-cb99ea01b6c8
2005-02-17 19:38:40 +00:00
José Matox
46cacd9dc5 Fix bug 1816.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9633 a592a061-630c-0410-9148-cb99ea01b6c8
2005-02-15 12:04:26 +00:00
José Matox
eb0de102db Unify the call to converters into LyX.py. (lyx2lyx)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9442 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-05 18:52:59 +00:00
José Matox
4bd289f1e3 Unify calling conventions for converter functions and modules. (lyx2lyx)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9433 a592a061-630c-0410-9148-cb99ea01b6c8
2005-01-05 10:57:37 +00:00
José Matox
742ffb3032 Move convertion code from the C++ source (where is never called) to lyx2lyx.
(longtables).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9336 a592a061-630c-0410-9148-cb99ea01b6c8
2004-12-03 18:33:19 +00:00
José Matox
b90881c010 Fix previous leftover transformation. (opt -> file)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9321 a592a061-630c-0410-9148-cb99ea01b6c8
2004-11-29 12:00:29 +00:00
José Matox
6c79118290 Reorganised lyx2lyx, transfering it knowleadge of the file format to LyX.py,
and using it as library. The lyx2lyx script now becomes a simple cliente.
Simple fix in the UserGuide.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8941 a592a061-630c-0410-9148-cb99ea01b6c8
2004-08-15 16:29:04 +00:00
José Matox
bc7f66b2b7 The big lyx2lyx rewrite.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8653 a592a061-630c-0410-9148-cb99ea01b6c8
2004-04-14 08:45:46 +00:00