@@ -34,15 +34,15 @@ To get started with ``fptokens``, type:
34
34
35
35
.. code-block :: python
36
36
37
- >> > import fptokens as fpt
37
+ import fptokens as fpt
38
38
39
39
To create a file name, type:
40
40
41
41
.. code-block :: python
42
42
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' ])
46
46
47
47
This created a file name with default settings, ``_ `` as the separator,
48
48
``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:
51
51
52
52
.. code-block :: python
53
53
54
- >> > filename.parse()
54
+ filename.parse()
55
55
56
56
To get the results of the parsing, type:
57
57
58
58
.. code-block :: python
59
59
60
- >> > print filename.tokens
61
- >> > [< Token: $ color$ > ]
60
+ print filename.tokens
61
+ [< Token: $ color$ > ]
62
62
63
63
The list of tokens could now be used to create permutations of the tokenised
64
64
file name for example for batch output of image assets.
65
65
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
+
66
80
Once tokens have been replaced with real-world data to create permutations,
67
81
the relevant folders can be created by typing:
68
82
69
83
.. code-block :: python
70
84
71
- >> > filename.make()
72
-
73
- .. _Full Documentation : http://fptokens.readthedocs.io/en/latest/
85
+ permutation.make()
0 commit comments