chaoss/grimoirelab-manuscripts

PROJECT-NAME not getting replaced in the report.pdf file

aswanipranjal opened this issue · 8 comments

In the report.pdf file generated at the end of running the manuscripts command with the necessary parameters and also providing -n <name of the report>, report.pdf still shows the name of the project as PROJECT-NAME and is unable to change it.

Problem might be in report.py

cmd = ['grep -rl PROJECT-NAME . | xargs sed -i s/PROJECT-NAME/' + project_replace + '/g']

I cannot reproduce this. If I run manuscripts as:

manuscripts -u http://localhost:9200 -n Myproject --data-sources git -d /tmp/report

I see in the front page "Myproject" as the name of the project... Where are you seeing "PROJECT-NAME"? Or maybe that's due to the version of grep you're using... Which one it is? Mine is:

$ grep --version
grep (GNU grep) 3.1
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

Hey @jgbarah, sorry for updating the progress of this issue so late.

I see in the front page "Myproject" as the name of the project... Where are you seeing "PROJECT-NAME"?

I see "PROJECT-NAME" instead of "Myproject" on the first page of the report.

The output of grep --version is:

grep (GNU grep) 3.1
Packaged by Homebrew
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.

I am using macOS High Sierra, maybe thats the problem. I'll try it on a linux machine and update on this issue.

I am using macOS High Sierra, maybe thats the problem. I'll try it on a linux machine and update on this issue.

Yes please, try to reproduce in Linux, I can't :-(.

In any case, the above code seems to be too much dependent on the actual tools (grep, xargs, sed) used. I think it would be better to change that line to use a pure Python mechanism, which hopefully would be much more portable. I'm labeling this as "Good First", since that seems not too complicated for anyone a bit fluent in Python.

the above code seems to be too much dependent on the actual tools (grep, xargs, sed) used. I think it would be better to change that line to use a pure Python mechanism, which hopefully would be much more portable

Yes @jgbarah I think that would be for the best. I'll start on this right away!

@jgbarah I tested Manuscripts on Ubuntu16.04 and it works, no problem there. The project name is getting replaced as required. There is some problem in the Mac version only then.

I'll work on removing the dependency on grep, xargs and sed by using a python based mechanism instead.

Thanks, @aswanipranjal !! Labeling this as bug, since it is a bug in Mac (at least for some setups).

@jgbarah, It won't be necessary now, but I figured out the bug for OSX. In the command:

'grep -rl PROJECT-NAME . | xargs sed -i s/PROJECT-NAME/' + project_replace + '/g'

We will have to provide the extension of the file in which we have to replace the string, with the -i flag as sed in OSX takes in a valid file extension with the -i option.
Example, if we want to change the PROJECT-NAME in all the .tex files then the command will be:

'grep -rl PROJECT-NAME . | xargs sed -i.tex s/PROJECT-NAME/' + project_replace + '/g'

I see. Thanks! In any case, I think fixing with pure Python would be better, if possible...