On Jan 30, 10:46 am, Jason Grout <jason-s...@creativetrax.com> wrote:

> Add a warnings handler which traps the Matplotlib deprecation
> warning.  This handler will compare the matplotlibrc with the one that
> was distributed in the last release (maybe by checking a hash value).
> If it is identical (i.e., the user hasn't modified the matplotlibrc),
> then *delete* the matplotlibrc.  This is a
> bit tricky, since the sage default matplotlibrc is not under version
> control (it's in $SAGE_ROOT), so we don't know what older copies looked
> like.

I have no opinion on whether the idea itself is worth implementing,
but if you want to know if the file has changed from
the original, you should probably include a hash of the file into
itself. matplotlibrc's format allows for comments, so this is
straightforward to do.
The person editing sage's default matplotlibrc should remember to
update the hash.

If a user edits matplotlibrc, the hash is almost surely not going to
match. If the user updates the hash .... well that's his own fault
then.

Some proof of concept shell script to do this:

----------------------------- sample for testing the hash
----------------------
#!/bin/sh
FILE=$1
REALHASH="#MD5-HASH: "`grep -v "^#MD5-HASH:" $FILE | md5sum`
STOREDHASH=`grep "^#MD5-HASH:" $FILE`
echo "R:" $REALHASH
echo "S:" $STOREDHASH
if [ "${REALHASH}" = "${STOREDHASH}" ]; then
  echo "match"
else
  echo "no match"
fi
-----------------------------------------------------------------------------------------

------------------ code for updating the stored hash
---------------------
#!/bin/sh
TMP=`mktemp`
FILE=$1
grep -v "^#MD5-HASH:" $FILE >> $TMP
HASH=`md5sum < $TMP`
mv $TMP $FILE
echo "#MD5-HASH: $HASH" >> $FILE
----------------------------------------------------------------------------------------

I'm sure the corresponding routines in Python would be both more
elegant and faster.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to 
sage-devel-unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to