File: scripting.html

package info (click to toggle)
puddletag 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,888 kB
  • sloc: python: 24,938; javascript: 21,828; xml: 964; makefile: 129; sh: 85
file content (356 lines) | stat: -rw-r--r-- 12,158 bytes parent folder | download | duplicates (2)
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Scripting functions reference &#8212; puddletag</title>
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="../_static/bootstrap-sphinx.css" type="text/css" />
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1'>
<meta name="apple-mobile-web-app-capable" content="yes">
<script type="text/javascript" src="../_static/js/jquery-1.11.0.min.js "></script>
<script type="text/javascript" src="../_static/js/jquery-fix.js "></script>
<script type="text/javascript" src="../_static/bootstrap-3.3.7/js/bootstrap.min.js "></script>
<script type="text/javascript" src="../_static/bootstrap-sphinx.js "></script>

  </head><body>

  <div id="navbar" class="navbar navbar-default navbar-fixed-top">
    <div class="container">
      <div class="navbar-header">
        <!-- .btn-navbar is used as the toggle for collapsed navbar content -->
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="../index.html">puddletag</a>
      </div>

        <div class="collapse navbar-collapse nav-collapse">
          <ul class="nav navbar-nav">
            <li class="divider-vertical"></li>
            
                <li><a href="../index.html">Home</a></li>
                <li><a href="../download.html">Download</a></li>
                <li><a href="../news.html">News</a></li>
                <li><a href="../docs.html">Documentation</a></li>
                <li><a href="https://github.com/puddletag/puddletag/issues">Issue Tracker</a></li>
                <li><a href="../screenshots.html">Screenshots</a></li>
                <li><a href="../about.html">About</a></li>
            
            
              
              
            
            
            
            
            
          </ul>

          
            
<form class="navbar-form navbar-right" action="../search.html" method="get">
 <div class="form-group">
  <input type="text" name="q" class="form-control" placeholder="Search" />
 </div>
  <input type="hidden" name="check_keywords" value="yes" />
  <input type="hidden" name="area" value="default" />
</form>
          
        </div>
    </div>
  </div>

<div class="container">
  <div class="row">
    <div class="body col-md-12 content" role="main">
      
  <div class="section" id="scripting-functions-reference">
<h1>Scripting functions reference<a class="headerlink" href="#scripting-functions-reference" title="Permalink to this headline">¶</a></h1>
<p>The scripting functions that puddletag supports are listed here. Use them where ever they can be used.</p>
<ul class="simple">
<li><p>For comparison functions, <strong>0</strong> and an empty string (<strong>“”</strong>) evaluate to <strong>False</strong>. Everything else evaluates to <strong>True</strong>.</p></li>
<li><p>Strings that contain commas must be enclode in double quotes (<strong>“</strong>).</p></li>
<li><p>White space before and after arguments will be discarded. Enclose the argument in quotes to preserve it as in <strong>$left(” One space.”, 3)</strong>.</p></li>
</ul>
<dl class="describe">
<dt>
<code class="sig-name descname">$ceiling()</code></dt>
<dd><p>For the floating point number x.y. Returns integer x + 1.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$and(a, b)</code></dt>
<dd><p>Returns True if both a and b evaluate to True. Returns False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$add(x,y)</code></dt>
<dd><p>Adds x and y</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$caps(string)</code></dt>
<dd><p>Capitalizes the first letter of each word in string and converts the rest to lower case.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$caps2(string)</code></dt>
<dd><p>Capitalizes the first letter of each word in string and leaves all other characters unchanged.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$caps3(string)</code></dt>
<dd><p>Capitalizes the first letter of the string and converts the rest to lower case.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$ceiling(number)</code></dt>
<dd><p>Returns the smallest integer that is greater than or equal to number.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$char(character)</code></dt>
<dd><p>Returns the ASCII character number of the character.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$div(x, y)</code></dt>
<dd><p>Divides x by y.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$floor()</code></dt>
<dd><p>For the floating point number x.y. Returns integer x.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$geql(x, y)</code></dt>
<dd><p>Returns True if x &gt;= y. False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$grtr(x, y)</code></dt>
<dd><p>Returns true if x &gt; y. False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$if(x, y, z)</code></dt>
<dd><p>If x is True, y is returned, otherwise z is returned.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$iflonger(a,b,x,y)</code></dt>
<dd><p>If string a is longer than string b, then x is returned, otherwise y.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$isdigit(x)</code></dt>
<dd><p>Returns true if x is a decimal number.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$left(string, n)</code></dt>
<dd><p>Leftmost n characters of string.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$len(string)</code></dt>
<dd><p>Returns the length of string.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$leql(x,y)</code></dt>
<dd><p>Returns True if x &lt;= y. False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$less(x,y)</code></dt>
<dd><p>Returns True if x &lt; y. False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$lower(string)</code></dt>
<dd><p>Converts string to lowercase.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$meta(field, n)</code></dt>
<dd><p>If field is multiple-valued, the field’s nth value. Note that it’s just the field name, <strong>field</strong> and not <strong>%field%</strong>.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$meta_sep(field, sep=', ')</code></dt>
<dd><p>If field is multiple-valued, returns the field’s values joined by sep. Otherwise just returns the field’s value.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$mid(string,n,i)</code></dt>
<dd><p>Returns first i characters of string, starting at n.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$mod(x,y)</code></dt>
<dd><p>Returns the remainder of x divided by y.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$mul(x,y)</code></dt>
<dd><p>Multiplies x by y.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$neql(x,y)</code></dt>
<dd><p>Returns True if x is not equal to y.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$not(x)</code></dt>
<dd><p>Returns False if x evaluates to True and vice versa.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$num(number, y)</code></dt>
<dd><p>Pads zeroes to number until it’s of length y. If number has excess zeroes and it’s length is less than y then these zeroes are removed.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$odd(x)</code></dt>
<dd><p>Returns True if x is odd.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$or(x,y)</code></dt>
<dd><p>Returns True if either x or y evaluates to True. False otherwise.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$rand()</code></dt>
<dd><p>Generates a pseudo-random number between 0 and 1.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$regex(text, regex, repl, matchcase=0)</code></dt>
<dd><p>Replaces all occurrences of <strong>regex</strong> with <strong>repl</strong> in text.</p>
<div class="line-block">
<div class="line"><strong>text</strong>: text to search, eg. <em>%artist%</em></div>
<div class="line"><strong>regex</strong>: regular expression to use as the search eg. <em>jay.*</em></div>
<div class="line"><strong>repl</strong>: Text to replace all matches of regex with. Can be pattern ex <em>$lower($1)</em>, but has to be quoted like in “$lower($1)” otherwise any scripting functions used will be run before the regular expression is evaluated.</div>
<div class="line"><strong>matchcase</strong>: Defaults to <em>0</em>. If <em>1</em>, will have case-sensitive matching.</div>
</div>
<p>See <a class="reference internal" href="function.html#replace-with-regexp"><span class="std std-ref">Replace with RegExp</span></a> for more examples.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$round()</code></dt>
<dd><p>For the floating point number x.y. Returns the integer x if y &lt; 0.5 else x + 1.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$replace(string, word, replaceword, matchcase, whole)</code></dt>
<dd><p>Replaces word in string with replaceword. If matchcase is true, a case-sensitive replace is done. Whole is true implies that only whole word matches are replaced.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$right(string, n)</code></dt>
<dd><p>Returns rightmost n characters in string.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$strip(string)</code></dt>
<dd><p>Removes leading and trailing whitespace from string.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$sub(x, y)</code></dt>
<dd><p>Subtracts y from x.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$to_ascii(x)</code></dt>
<dd><p>Converts all unicode chars in x to ASCII. It uses transliteration so 'abc äéç цы キウ 藏經' will become 'abc aec tsy kiu Cang Jing'. Characters that can't be converted will be removed.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$upper(string)</code></dt>
<dd><p>Converts string to uppercase.</p>
</dd></dl>

<dl class="describe">
<dt>
<code class="sig-name descname">$validate(string, y, chars)</code></dt>
<dd><p>Removes chars (defaults to <strong>/\*?;”|:</strong>) from string and replaces them with y if specified.</p>
</dd></dl>

</div>


    </div>
      
  </div>
</div>
<footer class="footer">
  <div class="container">
    <p class="pull-right">
      <a href="#">Back to top</a>
      
    </p>
    <p>
      This page and associated images are licensed under <a rel="license" href="http://www.apache.org/licenses/LICENSE-2.0">Apache Version 2.0</a>
	Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 3.4.3.<br/>
    </p>
  </div>
</footer>
  </body>
</html>