Home | Trees | Indices | Help |
|
---|
|
1 #!/usr/bin/env python 2 # -*- coding: utf-8 -*- 3 """ 4 This module contains tools for consistent naming of classes. 5 """ 6 7 # Copyright (C) 2008-2009 Martin Sandve Alnes and Simula Resarch Laboratory 8 # 9 # This file is part of SyFi. 10 # 11 # SyFi is free software: you can redistribute it and/or modify 12 # it under the terms of the GNU General Public License as published by 13 # the Free Software Foundation, either version 2 of the License, or 14 # (at your option) any later version. 15 # 16 # SyFi is distributed in the hope that it will be useful, 17 # but WITHOUT ANY WARRANTY; without even the implied warranty of 18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 # GNU General Public License for more details. 20 # 21 # You should have received a copy of the GNU General Public License 22 # along with SyFi. If not, see <http://www.gnu.org/licenses/>. 23 # 24 # First added: 2008-08-12 25 # Last changed: 2009-04-23 26 27 import re 28 import hashlib 29 3335 "Limit string length by computing a hash of it if it is too long." 36 if len(name) > max_name_length: 37 name = hashit(name) 38 return prefix + name3941 #return "%s_%s_%d" % (element.family, element.cell, element.degree) 42 s = repr(element).strip() 43 s = re.sub("[^\w]", "_", s) 44 s = re.sub("_+", "_", s) 45 s = s.strip("_") 46 return s47 50 5355 m = integral.measure() 56 prefix = "%s_integral_%s" % (m.domain_type(), m.domain_id()) 57 return short_name(prefix, form_name)5860 if options.code.form.name: 61 form_name = options.code.form.name 62 else: 63 form_name = hashit(form_signature + repr(options)) 64 return short_name("form_", form_name)65
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Jan 31 03:52:24 2013 | http://epydoc.sourceforge.net |