コード例 #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")])