#17308: Fix sws2rst
----------------------------+------------------------
Reporter: jdemeyer | Owner:
Type: defect | Status: new
Priority: minor | Milestone: sage-6.4
Component: scripts | Resolution:
Keywords: | Merged in:
Authors: | Reviewers:
Report Upstream: N/A | Work issues:
Branch: | Commit:
Dependencies: | Stopgaps:
----------------------------+------------------------
Comment (by kcrisman):
I checked it out, and the [https://mail.python.org/pipermail/python-
list/2008-January/482248.html sort of security implications] that using
`os.tempnam` has is very, very unlikely to hit someone creating a
tutorial. Otherwise I guess we could use
[https://docs.python.org/2/library/tempfile.html#tempfile.mkdtemp temp
file.mkdtemp()]. I'd appreciate your advice on which option seems better,
I haven't tested either.
{{{#!diff
diff --git a/src/bin/sage-sws2rst b/src/bin/sage-sws2rst
index 3028ef0..d6402b8 100755
--- a/src/bin/sage-sws2rst
+++ b/src/bin/sage-sws2rst
@@ -51,7 +51,8 @@ def process_sws(file_name):
#TODO: python complains about using tempnam, but I don't
#know hot to fix it or see any danger
# tempname = os.tempnam('.')
- tempname = os.path.join(tempfile.gettempdir(), file_name)
+ tempdirname = tempfile.mkdtemp()
+ tempname = os.path.join(tempdirname, file_name)
sws_file.extractall(tempname)
base_name = os.path.split(os.path.splitext(file_name)[0])[1]
base_name_clean = base_name.replace(' ','_')
@@ -101,7 +102,7 @@ def process_sws(file_name):
print "File at "+rst_file
print "Image directory at "+images_dir
- shutil.rmtree(tempname)
+ shutil.rmtree(tempdirname)
# Set the parser
diff --git a/src/doc/en/developer/sage_manuals.rst
b/src/doc/en/developer/sage_manuals.rst
index dff642a..03799b5 100644
--- a/src/doc/en/developer/sage_manuals.rst
+++ b/src/doc/en/developer/sage_manuals.rst
@@ -287,7 +287,7 @@ using the Mac app and have placed it in your
Applications directory.
However, you probably want to check whether it looks right first. So
next we will compile this file to html documentation.
- * Following the instructions of ``sage --sws2rst --sphinxify``,
+ * Follow the instructions of ``sage --sws2rst --sphinxify``. First,
we will open a Sage shell session, where all appropriate Sage
references already work properly::
@@ -305,7 +305,8 @@ using the Mac app and have placed it in your
Applications directory.
* Enter a name for you
* Type ``y`` for the question about using MathJax
- Now just do::
+ Keep note of the instructions; the main other thing to do is add
+ your file's name to ``index.rst``, and then just do::
make html
}}}
--
Ticket URL: <http://trac.sagemath.org/ticket/17308#comment:4>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.