Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Revert "Revert relocation of validation support code to the module it…
Browse files Browse the repository at this point in the history
…self"

This reverts commit 1198886.
  • Loading branch information
stefanoborini committed Mar 10, 2017
1 parent 1198886 commit cdde241
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions scripts/validation.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,7 @@ import warnings

import numpy


def to_camel_case(text, special={'cuds': 'CUDS'}):
""" Convert text to CamelCase (for class name)

Parameters
----------
text : str
The text to be converted

special : dict
If any substring of text (lower case) matches a key of `special`,
the substring is replaced by the value

Returns
-------
result : str
"""

def replace_func(matched):
# word should be lower case already
word = matched.group(0).strip("_")
if word in special:
# Handle special case
return special[word]
else:
# Capitalise the first character
return word[0].upper()+word[1:]

return re.sub(r'(_?[a-zA-Z]+)', replace_func, text.lower())


def without_cuba_prefix(string):
"""Removes the CUBA. prefix to the string if there."""
if is_cuba_key(string):
return string[5:]

return string
from scripts.utils import to_camel_case, without_cuba_prefix


def check_valid_shape(value, shape, cuba_key):
Expand Down

0 comments on commit cdde241

Please sign in to comment.