示例#1
0
 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)
示例#2
0
文件: curve.py 项目: StartE/yard
 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)
示例#3
0
 def get_curve_names():
     return sorted([
         cls.identifier for cls in itersubclasses(Curve)
         if hasattr(cls, "identifier")
     ])
示例#4
0
文件: curve.py 项目: StartE/yard
 def get_curve_names():
     return sorted([cls.identifier for cls in itersubclasses(Curve)
             if hasattr(cls, "identifier")])