Skip to content

Commit 2d6bcd0

Browse files
author
Florian Einfalt
committed
Update readme
1 parent 2e09a60 commit 2d6bcd0

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

README.rst

+22-10
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ To get started with ``fptokens``, type:
3434

3535
.. code-block:: python
3636
37-
>>> import fptokens as fpt
37+
import fptokens as fpt
3838
3939
To create a file name, type:
4040

4141
.. code-block:: python
4242
43-
>>> filename = fpt.Filename(root='/Users/demo/Desktop',
44-
folders=['assets', '$colors$'],
45-
base=['asset', '$colors$', '1200px'])
43+
filename = fpt.Filename(root='/Users/demo/Desktop',
44+
folders=['assets', '$colors$'],
45+
base=['asset', '$colors$', '1200px'])
4646
4747
This created a file name with default settings, ``_`` as the separator,
4848
``jpg`` as the extension and ``$`` as the escape character for the tokens.
@@ -51,23 +51,35 @@ To parse and convert the tokens of the file name to actual tokens, type:
5151

5252
.. code-block:: python
5353
54-
>>> filename.parse()
54+
filename.parse()
5555
5656
To get the results of the parsing, type:
5757

5858
.. code-block:: python
5959
60-
>>> print filename.tokens
61-
>>> [<Token: $color$>]
60+
print filename.tokens
61+
[<Token: $color$>]
6262
6363
The list of tokens could now be used to create permutations of the tokenised
6464
file name for example for batch output of image assets.
6565

66+
To create a generator of all permutations, define a set of data for each of the
67+
tokens with the token name as the argument name:
68+
69+
.. code-block:: python
70+
71+
for permutation in filename.resolve(colors=['white', 'black', 'red', 'blue']):
72+
# do something with the permutation
73+
print permutation.abspath
74+
# prints
75+
# /Users/demo/Desktop/assets/white/asset_white_1200px.jpg
76+
# /Users/demo/Desktop/assets/black/asset_black_1200px.jpg
77+
# /Users/demo/Desktop/assets/red/asset_red_1200px.jpg
78+
# /Users/demo/Desktop/assets/blue/asset_blue_1200px.jpg
79+
6680
Once tokens have been replaced with real-world data to create permutations,
6781
the relevant folders can be created by typing:
6882

6983
.. code-block:: python
7084
71-
>>> filename.make()
72-
73-
.. _Full Documentation: http://fptokens.readthedocs.io/en/latest/
85+
permutation.make()

0 commit comments

Comments
 (0)