created_at_from_name gives error #10

Closed
wichert opened this Issue Apr 26, 2012 · 2 comments

Projects

None yet

2 participants

@wichert
Contributor
wichert commented Apr 26, 2012

I was looking a bit at how to use created_at_from_name. First thing I did was load it by modifying config.yaml:

configurators:
  - strange_case.extensions.configurators.created_at_from_name

But not scase no longer runs:


  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/__main__.py", line 224, in run
    strange_case(CONFIG)
  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/__init__.py", line 68, in strange_case
    root_node = build_node(config, site_path, deploy_path, '')[0]
  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/processors.py", line 24, in build_node
    config = Registry.configurate(config, source_file)
  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/registry.py", line 73, in configurate
    config = configurator(source_file, config)
  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/configurators/__init__.py", line 9, in wrapper
    return function(source_file, config)
  File "/Users/wichert/Development/sc/lib/python2.7/site-packages/strange_case/extensions/configurator_created_at_from_name.py", line 20, in created_at_from_name
    matches = DATE_YMD_RE.match(config['name'])
KeyError: 'name'

At that point source_file points to the root directory of the project, which apparently does not get a name entry in the config

@wichert
Contributor
wichert commented Apr 26, 2012

This might be a more generic problem since I see the same thing happening with strip_extensions:

  File "/Users/wichert/Development/sc/src/StrangeCase/strange_case/extensions/configurator_strip_extensions.py", line 5, in strip_extensions
    if config['target_name'].endswith(extension):
KeyError: 'target_name'
@colinta
Owner
colinta commented Apr 26, 2012

In this case, you have replaced the configurators altogether. So all sorts of defaults were bypassed (the default setting of 'name' is apparent here)

For now, there is a temporary hack; this might become a permanent solution if I implement a YAML-DSL solution that I've been considering. It would make it easy to explicitly merge, replace, or delete configuration when merging/cloning config.

configurators +:
 - strange_case.extensions.configurators.created_at_from_name

but, since created_at_from_name is included by default, this is not needed.
it is needed for the file_stats plugin:

configurators +:
 - strange_case.extensions.configurators.file_ctime
 - strange_case.extensions.configurators.file_mtime
@colinta colinta closed this Apr 27, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment