forked from materialsproject/pymatgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pymatgen.util.io_utils.html
182 lines (166 loc) · 9.27 KB
/
pymatgen.util.io_utils.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>pymatgen.util.io_utils module — pymatgen 2019.5.1 documentation</title>
<link rel="stylesheet" href="_static/proBlue.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="shortcut icon" href="_static/favicon.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33990148-1']);
_gaq.push(['_trackPageview']);
</script>
</head><body>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">pymatgen 2019.5.1 documentation</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-pymatgen.util.io_utils">
<span id="pymatgen-util-io-utils-module"></span><h1>pymatgen.util.io_utils module<a class="headerlink" href="#module-pymatgen.util.io_utils" title="Permalink to this headline">¶</a></h1>
<dl class="class">
<dt id="pymatgen.util.io_utils.AtomicFile">
<em class="property">class </em><code class="descname">AtomicFile</code><span class="sig-paren">(</span><em>name</em>, <em>mode='w+b'</em>, <em>createmode=None</em>, <em>encoding=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#AtomicFile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.AtomicFile" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>This is a straight port of Alexander Saltanov’s atomicfile package.</p>
<p>Writeable file object that atomically writes a file.
All writes will go to a temporary file.
Call <code class="docutils literal notranslate"><span class="pre">close()</span></code> when you are done writing, and AtomicFile will rename
the temporary copy to the original name, making the changes visible.
If the object is destroyed without being closed, all your writes are
discarded.
If an <code class="docutils literal notranslate"><span class="pre">encoding</span></code> argument is specified, codecs.open will be called to open
the file in the wanted encoding.</p>
<dl class="method">
<dt id="pymatgen.util.io_utils.AtomicFile.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#AtomicFile.close"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.AtomicFile.close" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="pymatgen.util.io_utils.AtomicFile.discard">
<code class="descname">discard</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#AtomicFile.discard"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.AtomicFile.discard" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="function">
<dt id="pymatgen.util.io_utils.ask_yesno">
<code class="descname">ask_yesno</code><span class="sig-paren">(</span><em>question</em>, <em>default=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#ask_yesno"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.ask_yesno" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="pymatgen.util.io_utils.clean_lines">
<code class="descname">clean_lines</code><span class="sig-paren">(</span><em>string_list</em>, <em>remove_empty_lines=True</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#clean_lines"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.clean_lines" title="Permalink to this definition">¶</a></dt>
<dd><p>Strips whitespace, carriage returns and empty lines from a list of strings.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>string_list</strong> – List of strings</p></li>
<li><p><strong>remove_empty_lines</strong> – Set to True to skip lines which are empty after
stripping.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>List of clean strings with no whitespaces.</p>
</dd>
</dl>
</dd></dl>
<dl class="function">
<dt id="pymatgen.util.io_utils.micro_pyawk">
<code class="descname">micro_pyawk</code><span class="sig-paren">(</span><em>filename</em>, <em>search</em>, <em>results=None</em>, <em>debug=None</em>, <em>postdebug=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/pymatgen/util/io_utils.html#micro_pyawk"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pymatgen.util.io_utils.micro_pyawk" title="Permalink to this definition">¶</a></dt>
<dd><p>Small awk-mimicking search routine.</p>
<p>‘file’ is file to search through.
‘search’ is the “search program”, a list of lists/tuples with 3 elements;
i.e. [[regex,test,run],[regex,test,run],…]
‘results’ is a an object that your search program will have access to for
storing results.</p>
<p>Here regex is either as a Regex object, or a string that we compile into a
Regex. test and run are callable objects.</p>
<p>This function goes through each line in filename, and if regex matches that
line <em>and</em> test(results,line)==True (or test is None) we execute
run(results,match),where match is the match object from running
Regex.match.</p>
<p>The default results is an empty dictionary. Passing a results object let
you interact with it in run() and test(). Hence, in many occasions it is
thus clever to use results=self.</p>
<p>Author: Rickard Armiento, Ioannis Petousis</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>results</p>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/pymatgen.util.io_utils.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="nav-item nav-item-0"><a href="index.html">pymatgen 2019.5.1 documentation</a> »</li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2011, Pymatgen Development Team.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 2.0.1.
</div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
(function() {
var ga = document.createElement('script');
ga.src = ('https:' == document.location.protocol ?
'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
ga.setAttribute('async', 'true');
document.documentElement.firstChild.appendChild(ga);
})();
</script>
</div>
</body>
</html>