Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Dekel Tsur
On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
 Index: lib/lyx2lyx/lyxconvert_218.py
 ===
 RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
 retrieving revision 1.28
 diff -u -r1.28 lyxconvert_218.py
 --- lib/lyx2lyx/lyxconvert_218.py 2003/01/15 14:17:56 1.28
 +++ lib/lyx2lyx/lyxconvert_218.py 2003/01/16 01:34:36
 @@ -473,7 +473,7 @@
   i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
   if i == -1:
   break
 -type = lines[i][33:-3]
 +type = lines[i][33:-1]
  lines[i] = \\begin_inset FloatList +type
  i = i+1

This is wrong, as files created with LyX uses 
\begin_inset LatexCommand \listoffigures{}
The shortest solution is to use a regular expression:

type = re.search(rlistof(\w*), lines[i]).group(1)[:-1]



Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Michael Schmitt
On Fri, 17 Jan 2003, Dekel Tsur wrote:

 On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
  Index: lib/lyx2lyx/lyxconvert_218.py
  ===
  RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
  retrieving revision 1.28
  diff -u -r1.28 lyxconvert_218.py
  --- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
  +++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
  @@ -473,7 +473,7 @@
  i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
  if i == -1:
  break
  -type = lines[i][33:-3]
  +type = lines[i][33:-1]
   lines[i] = \\begin_inset FloatList +type
   i = i+1

In principle, we should fix reLyX in that case. However, a quick look at
the code tells me that it is probably much more difficult.

If the regex solves the problem, we should commit your proposal.

Michael








Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Dekel Tsur
On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
> Index: lib/lyx2lyx/lyxconvert_218.py
> ===
> RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
> retrieving revision 1.28
> diff -u -r1.28 lyxconvert_218.py
> --- lib/lyx2lyx/lyxconvert_218.py 2003/01/15 14:17:56 1.28
> +++ lib/lyx2lyx/lyxconvert_218.py 2003/01/16 01:34:36
> @@ -473,7 +473,7 @@
>   i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
>   if i == -1:
>   break
> -type = lines[i][33:-3]
> +type = lines[i][33:-1]
>  lines[i] = "\\begin_inset FloatList "+type
>  i = i+1

This is wrong, as files created with LyX uses 
\begin_inset LatexCommand \listoffigures{}
The shortest solution is to use a regular expression:

type = re.search(r"listof(\w*)", lines[i]).group(1)[:-1]



Re: [PATCH] reLyX and lyx2lyx patches

2003-01-16 Thread Michael Schmitt
On Fri, 17 Jan 2003, Dekel Tsur wrote:

> On Thu, Jan 16, 2003 at 02:40:08AM +0100, Michael Schmitt wrote:
> > Index: lib/lyx2lyx/lyxconvert_218.py
> > ===
> > RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
> > retrieving revision 1.28
> > diff -u -r1.28 lyxconvert_218.py
> > --- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
> > +++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
> > @@ -473,7 +473,7 @@
> > i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
> > if i == -1:
> > break
> > -type = lines[i][33:-3]
> > +type = lines[i][33:-1]
> >  lines[i] = "\\begin_inset FloatList "+type
> >  i = i+1

In principle, we should fix reLyX in that case. However, a quick look at
the code tells me that it is probably much more difficult.

If the regex solves the problem, we should commit your proposal.

Michael








[PATCH] reLyX and lyx2lyx patches

2003-01-15 Thread Michael Schmitt
Hi,

below please find two patches for lyx2lyx and reLyX. I have already 
posted the patch for reLyX but I am not sure whether I used plain text 
when sending the email.

The following two bugs are fixed:

 - lyx2lyx does not translate listoffigures/listoftables correctly
 - reLyX fails if there is a directory with the same name as
   the basename of a TeX file that is used in an \include statement

Quite trivial stuff, I hope.

As usual, please check and commit.

Michael
Index: lib/lyx2lyx/lyxconvert_218.py
===
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
retrieving revision 1.28
diff -u -r1.28 lyxconvert_218.py
--- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
+++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
@@ -473,7 +473,7 @@
i = find_token(lines, \\begin_inset LatexCommand \\listof, i)
if i == -1:
break
-type = lines[i][33:-3]
+type = lines[i][33:-1]
 lines[i] = \\begin_inset FloatList +type
 i = i+1
 
Index: lib/reLyX/reLyXmain.pl
===
RCS file: /cvs/lyx/lyx-devel/lib/reLyX/reLyXmain.pl,v
retrieving revision 1.4
diff -u -r1.4 reLyXmain.pl
--- lib/reLyX/reLyXmain.pl  2001/08/31 07:54:05 1.4
+++ lib/reLyX/reLyXmain.pl  2003/01/16 01:34:43
@@ -145,9 +145,9 @@
 # Read personal syntax.default, or system-wide if there isn't a personal one
 # Then read other syntax files, given by the -s option
 my $default_file = $dot_lyxdir/reLyX/$syntaxname;
-if (! -e $default_file) {
+if (! -f $default_file) {
 $default_file = $lyxdir/reLyX/$syntaxname;
-die cannot find default syntax file $default_file unless -e $default_file;
+die cannot find default syntax file $default_file unless -f $default_file;
 }
 my @syntaxfiles = ($default_file);
 push (@syntaxfiles, (split(/,/,$opt_s))) if defined $opt_s;
@@ -288,9 +288,9 @@
 #$path .= '/' unless $path =~ /\/$/; # fix BUG in perl5.002 fileparse!
 
 # Try adding .tex to filename if you can't find the file the user input
-unless (-e $File) {
+unless (-f $File) {
 if (! $suffix) { # didn't have a valid suffix. Try adding one
-   if (-e $File.tex) {
+   if (-f $File.tex) {
$suffix = .tex;
} else {
warn \nCan't find input file $File or $File.tex\n;
@@ -322,7 +322,10 @@
 # Check for files that already exist
 my $lname = $PathBase . .lyx;
 if (-e $lname) {
-   if ($opt_f) {
+   if (-d $lname) {
+   warn \nLyX file $lname already exists and is a directory.\n;
+   return @return_error;
+   } elsif ($opt_f) {
warn Will overwrite file $lname\n if $opt_d;
} else {
warn \nLyX file $lname already exists. Use -f to overwrite\n;



[PATCH] reLyX and lyx2lyx patches

2003-01-15 Thread Michael Schmitt
Hi,

below please find two patches for lyx2lyx and reLyX. I have already 
posted the patch for reLyX but I am not sure whether I used plain text 
when sending the email.

The following two bugs are fixed:

 - lyx2lyx does not translate listoffigures/listoftables correctly
 - reLyX fails if there is a directory with the same name as
   the basename of a TeX file that is used in an "\include" statement

Quite trivial stuff, I hope.

As usual, please check and commit.

Michael
Index: lib/lyx2lyx/lyxconvert_218.py
===
RCS file: /cvs/lyx/lyx-devel/lib/lyx2lyx/lyxconvert_218.py,v
retrieving revision 1.28
diff -u -r1.28 lyxconvert_218.py
--- lib/lyx2lyx/lyxconvert_218.py   2003/01/15 14:17:56 1.28
+++ lib/lyx2lyx/lyxconvert_218.py   2003/01/16 01:34:36
@@ -473,7 +473,7 @@
i = find_token(lines, "\\begin_inset LatexCommand \\listof", i)
if i == -1:
break
-type = lines[i][33:-3]
+type = lines[i][33:-1]
 lines[i] = "\\begin_inset FloatList "+type
 i = i+1
 
Index: lib/reLyX/reLyXmain.pl
===
RCS file: /cvs/lyx/lyx-devel/lib/reLyX/reLyXmain.pl,v
retrieving revision 1.4
diff -u -r1.4 reLyXmain.pl
--- lib/reLyX/reLyXmain.pl  2001/08/31 07:54:05 1.4
+++ lib/reLyX/reLyXmain.pl  2003/01/16 01:34:43
@@ -145,9 +145,9 @@
 # Read personal syntax.default, or system-wide if there isn't a personal one
 # Then read other syntax files, given by the -s option
 my $default_file = "$dot_lyxdir/reLyX/$syntaxname";
-if (! -e $default_file) {
+if (! -f $default_file) {
 $default_file = "$lyxdir/reLyX/$syntaxname";
-die "cannot find default syntax file $default_file" unless -e $default_file;
+die "cannot find default syntax file $default_file" unless -f $default_file;
 }
 my @syntaxfiles = ($default_file);
 push (@syntaxfiles, (split(/,/,$opt_s))) if defined $opt_s;
@@ -288,9 +288,9 @@
 #$path .= '/' unless $path =~ /\/$/; # fix BUG in perl5.002 fileparse!
 
 # Try adding .tex to filename if you can't find the file the user input
-unless (-e $File) {
+unless (-f $File) {
 if (! $suffix) { # didn't have a valid suffix. Try adding one
-   if (-e "$File.tex") {
+   if (-f "$File.tex") {
$suffix = ".tex";
} else {
warn "\nCan't find input file $File or $File.tex\n";
@@ -322,7 +322,10 @@
 # Check for files that already exist
 my $lname = $PathBase . ".lyx";
 if (-e $lname) {
-   if ($opt_f) {
+   if (-d $lname) {
+   warn "\nLyX file $lname already exists and is a directory.\n";
+   return @return_error;
+   } elsif ($opt_f) {
warn "Will overwrite file $lname\n" if $opt_d;
} else {
warn "\nLyX file $lname already exists. Use -f to overwrite\n";