def find_class_by_name(name): """Finds the class corresponding to a given short name used in command line arguments across the whole ``yard`` package. `name` is matched against the ``identifier`` class-level properties of all the subclasses of `Curve` to find the subclass to be constructed. Returns the found subclass (not an instance of it), or raises ``ValueError`` if an invalid name was given. """ name = name.lower() for cls in itersubclasses(Curve): if hasattr(cls, "identifier") and cls.identifier == name: return cls raise ValueError("no such curve type: %s" % name)
def get_curve_names(): return sorted([ cls.identifier for cls in itersubclasses(Curve) if hasattr(cls, "identifier") ])
def get_curve_names(): return sorted([cls.identifier for cls in itersubclasses(Curve) if hasattr(cls, "identifier")])