Mercurial > piecrust2
annotate piecrust/chefutil.py @ 334:b034f6f15e22
bake: Several bug taxonomy-related fixes for incorrect incremental bakes.
* Improve how the baker processes taxonomy terms and figures out what needs
to be re-baked or not.
* Create bake entries for clean taxnomy terms so they're not deleted by an
incremental bake.
* Add more information to bake records.
* Slugify taxonomy terms is now done by the route in one place.
* Fix a bug where the cache key for invalidating rendered segments was not
computed the same way as when the caching was done.
* Fix how term combinations are passed around, rendered, printed, parsed, etc.
(TODO: more word needed in the routing functions)
* Expose to the template whether a taxonomy term is a combination or not.
* Display term combinations better in the built-in theme.
* Rename `route.taxonomy` to `route.taxonomy_name` to prevent confusion.
* Add options to show bake records for previous bakes.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Fri, 03 Apr 2015 10:59:50 -0700 |
parents | a561fbad0b7f |
children | e7b865f8f335 |
rev | line source |
---|---|
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
1 import time |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
2 from colorama import Fore |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
3 |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
4 |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
99
diff
changeset
|
5 def format_timed(start_time, message, indent_level=0, colored=True): |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
6 end_time = time.clock() |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
99
diff
changeset
|
7 indent = indent_level * ' ' |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
8 time_str = '%8.1f ms' % ((end_time - start_time) * 1000.0) |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
9 if colored: |
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
10 return '[%s%s%s] %s' % (Fore.GREEN, time_str, Fore.RESET, message) |
120
133845647083
Better error management and removal support in baking/processing.
Ludovic Chabant <ludovic@chabant.com>
parents:
99
diff
changeset
|
11 return '%s[%s] %s' % (indent, time_str, message) |
3
f485ba500df3
Gigantic change to basically make PieCrust 2 vaguely functional.
Ludovic Chabant <ludovic@chabant.com>
parents:
diff
changeset
|
12 |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
13 |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
14 def log_friendly_exception(logger, ex): |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
15 indent = '' |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
16 while ex: |
272
a561fbad0b7f
logging: If an error doesn't have a message, print its type.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
17 ex_msg = str(ex) |
a561fbad0b7f
logging: If an error doesn't have a message, print its type.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
18 if not ex_msg: |
a561fbad0b7f
logging: If an error doesn't have a message, print its type.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
19 ex_msg = '%s exception was thrown' % type(ex).__name__ |
a561fbad0b7f
logging: If an error doesn't have a message, print its type.
Ludovic Chabant <ludovic@chabant.com>
parents:
120
diff
changeset
|
20 logger.error('%s%s' % (indent, ex_msg)) |
39
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
21 indent += ' ' |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
22 ex = ex.__cause__ |
2f717f961996
Better error reporting and cache validation.
Ludovic Chabant <ludovic@chabant.com>
parents:
3
diff
changeset
|
23 |
99
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
24 |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
25 def print_help_item(s, title, description, margin=4, align=25): |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
26 s.write(margin * ' ') |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
27 s.write(title) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
28 spacer = (align - margin - len(title) - 1) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
29 if spacer <= 0: |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
30 s.write("\n") |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
31 s.write(' ' * align) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
32 else: |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
33 s.write(' ' * spacer) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
34 s.write(description) |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
35 s.write("\n") |
8703be118430
Changes to `help` command and extendable commands:
Ludovic Chabant <ludovic@chabant.com>
parents:
39
diff
changeset
|
36 |