texlive[72708] Master/texmf-dist: latex2pydata (30oct24)
commits+karl at tug.org
commits+karl at tug.org
Wed Oct 30 21:02:16 CET 2024
Revision: 72708
https://tug.org/svn/texlive?view=revision&revision=72708
Author: karl
Date: 2024-10-30 21:02:16 +0100 (Wed, 30 Oct 2024)
Log Message:
-----------
latex2pydata (30oct24)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/latex2pydata/CHANGELOG.md
trunk/Master/texmf-dist/doc/latex/latex2pydata/latex2pydata.pdf
trunk/Master/texmf-dist/source/latex/latex2pydata/latex2pydata.dtx
trunk/Master/texmf-dist/tex/latex/latex2pydata/latex2pydata.sty
Modified: trunk/Master/texmf-dist/doc/latex/latex2pydata/CHANGELOG.md
===================================================================
--- trunk/Master/texmf-dist/doc/latex/latex2pydata/CHANGELOG.md 2024-10-30 20:01:53 UTC (rev 72707)
+++ trunk/Master/texmf-dist/doc/latex/latex2pydata/CHANGELOG.md 2024-10-30 20:02:16 UTC (rev 72708)
@@ -1,6 +1,13 @@
# Changelog — latex2pydata LaTeX package
+## v0.3.0 (2024/10/16)
+
+* Replaced buffer length counters with macros to prevent issues with
+ `\includeonly` resetting counters.
+
+
+
## v0.2.0 (2024-05-16)
* Operations on file handles, file names, and buffers are now global.
@@ -34,6 +41,7 @@
`tcolorbox`.
+
## v0.1.0 (2023-11-19)
* Initial release.
Modified: trunk/Master/texmf-dist/doc/latex/latex2pydata/latex2pydata.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/latex2pydata/latex2pydata.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/latex2pydata/latex2pydata.dtx 2024-10-30 20:01:53 UTC (rev 72707)
+++ trunk/Master/texmf-dist/source/latex/latex2pydata/latex2pydata.dtx 2024-10-30 20:02:16 UTC (rev 72708)
@@ -26,7 +26,7 @@
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{latex2pydata}
%<*package>
- [2024/05/16 v0.2.0 latex2pydata - write data to file in Python literal format]
+ [2024/10/16 v0.3.0 latex2pydata - write data to file in Python literal format]
%</package>
%
%<*driver>
@@ -482,7 +482,7 @@
%
% Key-value data can be written to file once a dict is opened with |\pydatawritedictopen|. It is also possible to accumulate key-value data in a ``buffer.'' This is convenient when the data serves as input to an external program that generates cached content. Buffered data can be hashed in memory without being written to file, so the existence of cached content can be checked efficiently.
%
-% A buffer consists of a sequence of macros of the form |\|\meta{buffername}|line|\meta{n}, where each line of data corresponds to a macro and \meta{n} is an integer greater than or equal to one (one-based indexing). The length of the buffer is stored in the counter \meta{buffername}|length|. Buffers are limited to containing comma-separated key-value data, without any opening or closing dict delimiters |{}|.
+% A buffer consists of a sequence of macros of the form |\|\meta{buffername}|line|\meta{n}, where each line of data corresponds to a macro and \meta{n} is an integer greater than or equal to one (one-based indexing). The length of the buffer is stored in the macro |\|\meta{buffername}|length|. Buffers are limited to containing comma-separated key-value data, without any opening or closing dict delimiters |{}|.
%
% All buffer commands that set the buffer or modify the buffer operate globally (|\global|, |\gdef|, etc.).
%
@@ -492,10 +492,10 @@
% \DescMacro{\pydatasetbuffername\marg{buffername}}
% Initialize a new buffer if \meta{buffername} has not been used previously, and configure all buffer operations to use \meta{buffername}.
%
-% \meta{buffername} is used as a base name for creating the buffer line macros of the form |\|\meta{buffername}|line|\meta{n} and the buffer length counter \meta{buffername}|length|.
+% \meta{buffername} is used as a base name for creating the buffer line macros of the form |\|\meta{buffername}|line|\meta{n} and the buffer length macro |\|\meta{buffername}|length|.
%
% \DescMacro{\pydataclearbuffername\marg{buffername}}
-% Delete the specified buffer. |\let| all line macros |\|\meta{buffername}|line|\meta{n} to an undefined macro, and set the length counter \meta{buffername}|length| to zero.
+% Delete the specified buffer. |\let| all line macros |\|\meta{buffername}|line|\meta{n} to an undefined macro, and set the length macro |\|\meta{buffername}|length| to zero.
%
%
% \subsubsection{Special buffer operations}
@@ -814,7 +814,7 @@
%
% Key-value data can be written directly to file once a dict is opened. It is also possible to accumulate key-value data in a ``buffer.'' This is convenient when the data serves as input to an external program that generates cached content. Buffered data can be hashed in memory without being written to file, so the existence of cached content can be checked efficiently.
%
-% The buffer consists of a sequence of macros of the form |\<buffer_name>line<n>|, where each line of data corresponds to a macro and |<n>| is an integer greater than or equal to one. The length of the buffer is stored in the counter |<buffer_name>length|. The buffer includes comma-separated key-value data, without any opening or closing dict delimiters |{}|.
+% The buffer consists of a sequence of macros of the form |\<buffer_name>line<n>|, where each line of data corresponds to a macro and |<n>| is an integer greater than or equal to one. The length of the buffer is stored in the macro |\<buffer_name>length|. The buffer includes comma-separated key-value data, without any opening or closing dict delimiters |{}|.
%
% \begin{macro}{pydata at bufferindex}
% Counter for looping through buffers.
@@ -824,8 +824,8 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\pydatasetbuffername, \pydata at buffername, \pydata at bufferlinename, \pydata at bufferlengthname}
-% Set the buffer base name and create a corresponding length counter if it does not exist.
+% \begin{macro}{\pydatasetbuffername, \pydata at buffername, \pydata at bufferlinename, \pydata at bufferlengthname, \pydata at bufferlengthmacro}
+% Set the buffer base name and create a corresponding length macro if it does not exist.
% \begin{macrocode}
\def\pydatasetbuffername#1{%
\ifbool{pydata at bufferhaskey}%
@@ -834,10 +834,12 @@
\gdef\pydata at buffername{#1}%
\gdef\pydata at bufferlinename{#1line}%
\gdef\pydata at bufferlengthname{#1length}%
- \ifcsname c@\pydata at bufferlengthname\endcsname
+ \ifcsname\pydata at bufferlengthname\endcsname
\else
- \expandafter\newcounter\expandafter{\pydata at bufferlengthname}%
- \fi}
+ \expandafter\gdef\csname\pydata at bufferlengthname\endcsname{0}%
+ \fi
+ \expandafter\gdef\expandafter\pydata at bufferlengthmacro\expandafter{%
+ \csname\pydata at bufferlengthname\endcsname}}
\pydatasetbuffername{pydata at defaultbuffer}
% \end{macrocode}
% \end{macro}
@@ -846,7 +848,7 @@
% Write existing buffer macros to file handle.
% \begin{macrocode}
\def\pydatawritebuffer{%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}<1\relax
+ \ifnum\pydata at bufferlengthmacro<1\relax
\pydata at error{Cannot write empty buffer}%
\fi
\pydata at checkfilehandle
@@ -856,8 +858,7 @@
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot write buffer when a buffered key is waiting for a value}}{}%
\setcounter{pydata at bufferindex}{1}%
- \loop\unless\ifnum\value{pydata at bufferindex}>%
- \expandafter\value\expandafter{\pydata at bufferlengthname}\relax
+ \loop\unless\ifnum\value{pydata at bufferindex}>\pydata at bufferlengthmacro\relax
\immediate\write\pydata at filehandle{%
\csname\pydata at bufferlinename\arabic{pydata at bufferindex}\endcsname}%
\stepcounter{pydata at bufferindex}%
@@ -872,17 +873,17 @@
% \begin{macrocode}
\def\pydataclearbuffername#1{%
\def\pydata at clearbuffername{#1}%
- \ifcsname c@#1length\endcsname
+ \ifcsname#1length\endcsname
\else
\pydata at error{Buffer #1 does not exist}%
\fi
\setcounter{pydata at bufferindex}{1}%
- \loop\unless\ifnum\value{pydata at bufferindex}>\value{#1length}\relax
+ \loop\unless\ifnum\value{pydata at bufferindex}>\csname#1length\endcsname\relax
\expandafter\global\expandafter\let
\csname#1line\arabic{pydata at bufferindex}\endcsname\pydata at undefined
\stepcounter{pydata at bufferindex}%
\repeat
- \setcounter{#1length}{0}%
+ \expandafter\gdef\csname#1length\endcsname{0}%
\setcounter{pydata at bufferindex}{0}%
\ifx\pydata at clearbuffername\pydata at buffername
\boolfalse{pydata at bufferhaskey}%
@@ -896,7 +897,7 @@
% \begin{macrocode}
\def\pydatabuffermdfivesum{%
\pdf at mdfivesum{%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}<1
+ \ifnum\pydata at bufferlengthmacro<1
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
@@ -904,12 +905,12 @@
{}{\pydatabuffermdfivesum at i{1}}}}
\def\pydatabuffermdfivesum at i#1{%
\csname\pydata at bufferlinename#1\endcsname^^J%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}=#1
+ \ifnum\pydata at bufferlengthmacro=#1
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
- {\expandafter\pydatabuffermdfivesum at i\expandafter{\the\numexpr#1+1 }}}
+ {\expandafter\pydatabuffermdfivesum at i\expandafter{\the\numexpr#1+1\relax}}}
% \end{macrocode}
% \end{macro}
%
@@ -1164,10 +1165,9 @@
\gdef\pydatabufferkey at i#1{%
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot buffer a key when waiting for a value}}{}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1}:%
}%
\booltrue{pydata at bufferhaskey}}
@@ -1193,10 +1193,9 @@
\gdef\pydatabuffervalue at i#1{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1},%
}%
\boolfalse{pydata at bufferhaskey}}
@@ -1234,10 +1233,9 @@
\gdef\pydatabufferkeyvalue at ii#1#2{%
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot buffer a key when waiting for a value}}{}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1}: \pydata at quotestr{#2},%
}}
\gdef\pydatabufferkeyedefvalue{%
@@ -1276,28 +1274,25 @@
\gdef\pydatabuffermlvaluestart{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at mlstropen
}}
\gdef\pydatabuffermlvalueline#1{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at escstrtext{#1}%
}}
\gdef\pydatabuffermlvalueend{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at mlstrclose,%
}%
\boolfalse{pydata at bufferhaskey}}
Modified: trunk/Master/texmf-dist/tex/latex/latex2pydata/latex2pydata.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/latex2pydata/latex2pydata.sty 2024-10-30 20:01:53 UTC (rev 72707)
+++ trunk/Master/texmf-dist/tex/latex/latex2pydata/latex2pydata.sty 2024-10-30 20:02:16 UTC (rev 72708)
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{latex2pydata}
- [2024/05/16 v0.2.0 latex2pydata - write data to file in Python literal format]
+ [2024/10/16 v0.3.0 latex2pydata - write data to file in Python literal format]
\def\pydata at error#1{%
\PackageError{latex2pydata}{#1}{}%
\batchmode\read -1 to \pydata at exitnow}
@@ -164,13 +164,15 @@
\gdef\pydata at buffername{#1}%
\gdef\pydata at bufferlinename{#1line}%
\gdef\pydata at bufferlengthname{#1length}%
- \ifcsname c@\pydata at bufferlengthname\endcsname
+ \ifcsname\pydata at bufferlengthname\endcsname
\else
- \expandafter\newcounter\expandafter{\pydata at bufferlengthname}%
- \fi}
+ \expandafter\gdef\csname\pydata at bufferlengthname\endcsname{0}%
+ \fi
+ \expandafter\gdef\expandafter\pydata at bufferlengthmacro\expandafter{%
+ \csname\pydata at bufferlengthname\endcsname}}
\pydatasetbuffername{pydata at defaultbuffer}
\def\pydatawritebuffer{%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}<1\relax
+ \ifnum\pydata at bufferlengthmacro<1\relax
\pydata at error{Cannot write empty buffer}%
\fi
\pydata at checkfilehandle
@@ -180,8 +182,7 @@
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot write buffer when a buffered key is waiting for a value}}{}%
\setcounter{pydata at bufferindex}{1}%
- \loop\unless\ifnum\value{pydata at bufferindex}>%
- \expandafter\value\expandafter{\pydata at bufferlengthname}\relax
+ \loop\unless\ifnum\value{pydata at bufferindex}>\pydata at bufferlengthmacro\relax
\immediate\write\pydata at filehandle{%
\csname\pydata at bufferlinename\arabic{pydata at bufferindex}\endcsname}%
\stepcounter{pydata at bufferindex}%
@@ -189,17 +190,17 @@
\setcounter{pydata at bufferindex}{0}}
\def\pydataclearbuffername#1{%
\def\pydata at clearbuffername{#1}%
- \ifcsname c@#1length\endcsname
+ \ifcsname#1length\endcsname
\else
\pydata at error{Buffer #1 does not exist}%
\fi
\setcounter{pydata at bufferindex}{1}%
- \loop\unless\ifnum\value{pydata at bufferindex}>\value{#1length}\relax
+ \loop\unless\ifnum\value{pydata at bufferindex}>\csname#1length\endcsname\relax
\expandafter\global\expandafter\let
\csname#1line\arabic{pydata at bufferindex}\endcsname\pydata at undefined
\stepcounter{pydata at bufferindex}%
\repeat
- \setcounter{#1length}{0}%
+ \expandafter\gdef\csname#1length\endcsname{0}%
\setcounter{pydata at bufferindex}{0}%
\ifx\pydata at clearbuffername\pydata at buffername
\boolfalse{pydata at bufferhaskey}%
@@ -206,7 +207,7 @@
\fi}
\def\pydatabuffermdfivesum{%
\pdf at mdfivesum{%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}<1
+ \ifnum\pydata at bufferlengthmacro<1
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
@@ -214,12 +215,12 @@
{}{\pydatabuffermdfivesum at i{1}}}}
\def\pydatabuffermdfivesum at i#1{%
\csname\pydata at bufferlinename#1\endcsname^^J%
- \ifnum\expandafter\value\expandafter{\pydata at bufferlengthname}=#1
+ \ifnum\pydata at bufferlengthmacro=#1
\expandafter\@gobble
\else
\expandafter\@firstofone
\fi
- {\expandafter\pydatabuffermdfivesum at i\expandafter{\the\numexpr#1+1 }}}
+ {\expandafter\pydatabuffermdfivesum at i\expandafter{\the\numexpr#1+1\relax}}}
\begingroup
\catcode`\"=12\relax
\begingroup
@@ -372,10 +373,9 @@
\gdef\pydatabufferkey at i#1{%
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot buffer a key when waiting for a value}}{}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1}:%
}%
\booltrue{pydata at bufferhaskey}}
@@ -395,10 +395,9 @@
\gdef\pydatabuffervalue at i#1{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1},%
}%
\boolfalse{pydata at bufferhaskey}}
@@ -430,10 +429,9 @@
\gdef\pydatabufferkeyvalue at ii#1#2{%
\ifbool{pydata at bufferhaskey}%
{\pydata at error{Cannot buffer a key when waiting for a value}}{}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at quotestr{#1}: \pydata at quotestr{#2},%
}}
\gdef\pydatabufferkeyedefvalue{%
@@ -465,28 +463,25 @@
\gdef\pydatabuffermlvaluestart{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at mlstropen
}}
\gdef\pydatabuffermlvalueline#1{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at escstrtext{#1}%
}}
\gdef\pydatabuffermlvalueend{%
\ifbool{pydata at bufferhaskey}%
{}{\pydata at error{Cannot buffer value when waiting for a key}}%
- \expandafter\stepcounter\expandafter{\pydata at bufferlengthname}%
- \expandafter\xdef\csname
- \pydata at bufferlinename\expandafter\arabic\expandafter{\pydata at bufferlengthname}%
- \endcsname{%
+ \expandafter\xdef\pydata at bufferlengthmacro{%
+ \the\numexpr\pydata at bufferlengthmacro+1\relax}%
+ \expandafter\xdef\csname\pydata at bufferlinename\pydata at bufferlengthmacro\endcsname{%
\pydata at mlstrclose,%
}%
\boolfalse{pydata at bufferhaskey}}
More information about the tex-live-commits
mailing list.