-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/FlyRanch/figurefirst
- Loading branch information
Showing
4 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
FigureFirst is a python library to decorate and parse SVG files so they can serve as layout documents for matplotlib figures. | ||
|
||
See our github page for readme and examples: http://flyranch.github.io/figurefirst/ | ||
|
||
Read the docs: http://figurefirst.readthedocs.io/en/latest/source/figurefirst.html#module-figurefirst | ||
|
||
Read our Scipy 2017 proceedings: http://conference.scipy.org/proceedings/scipy2017/lindsay.html | ||
|
||
If you use FigureFirst, please cite the above paper to help others find FigureFirst. | ||
If you use FigureFirst, please cite the above paper to help others find FigureFirst. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#utility functions for dealing with svg files. | ||
|
||
def replace_non_unique(in_filename,out_filename, | ||
search_string = 'text_to_replace', | ||
prefix = ''): | ||
"""parse the document 'in_filename' and replace all | ||
instances of the string 'search_string' with the | ||
unique string 'prefix_x'. | ||
Parameters | ||
---------- | ||
in_filename : name of the file to parse | ||
out_filename : name of the file to write. If | ||
out_filename is the same as in_filename | ||
then the old document will be overwritten. | ||
search_string : target string to search and replace. Note: | ||
when applying this function to svg layout documents | ||
take care that you don't target strings that are | ||
common strings in the SVG language. e.g. 'label' | ||
prefix : the prefix will be appended with a number and used | ||
to replace each occurance of the search string. | ||
""" | ||
|
||
with open(in_filename,'rt') as inf: | ||
strdta = inf.read() | ||
slist = strdta.split(search_string) | ||
outstr = ''.join([s + prefix + '_%s'%(i) for i,s in enumerate(slist[:-1])]) | ||
outstr += slist[-1] | ||
with open(out_filename,'wt') as outf: | ||
outf.write(outstr) |