示例#1
0
def get_template(t):
    """Find template file *t* and return its real path.

   *t* can be a single string or a list of strings. A string
   should be one of

   1. a relative or absolute path,
   2. a file in one of the directories listed in :data:`bornprofiler.config.path`,
   3. a filename in the package template directory (defined in the template dictionary
      :data:`bornprofiler.config.templates`) or
   4. a key into :data:`~bornprofiler.config.templates`.

   The first match (in this order) is returned. If the argument is a
   single string then a single string is returned, otherwise a list
   of strings.

   :Arguments: *t* : template file or key (string or list of strings)
   :Returns:   os.path.realpath(*t*) (or a list thereof)
   :Raises:    :exc:`ValueError` if no file can be located.

   """
    templates = [_get_template(s) for s in utilities.asiterable(t)]
    if len(templates) == 1:
        return templates[0]
    return templates
示例#2
0
def get_template(t):
    """Find template file *t* and return its real path.

    *t* can be a single string or a list of strings. A string
    should be one of

    1. a relative or absolute path,
    2. a file in one of the directories listed in :data:`gromacs.config.path`,
    3. a filename in the package template directory (defined in the template dictionary
       :data:`gromacs.config.templates`) or
    4. a key into :data:`~gromacs.config.templates`.

    The first match (in this order) is returned. If the argument is a
    single string then a single string is returned, otherwise a list
    of strings.

    :Arguments: *t* : template file or key (string or list of strings)
    :Returns:   os.path.realpath(*t*) (or a list thereof)
    :Raises:    :exc:`ValueError` if no file can be located.

    """
    templates = [_get_template(s) for s in utilities.asiterable(t)]
    if len(templates) == 1:
         return templates[0]
    return templates
示例#3
0
 def _process_window_numbers(self, windows=None):
     """Window numbers are 0-based."""
     if windows is None:
         windows = numpy.arange(self.numPoints)
     else:
         windows = numpy.unique(asiterable(windows))
     if windows.min() < 0 or windows.max() >= self.numPoints:
         errmsg = "window numbers must be between 0 and %d inclusive." % (
             self.numPoints - 1)
         logger.fatal(errmsg)
         raise ValueError(errmsg)
     return windows
示例#4
0
def get_templates(t):
    """Find template file(s) *t* and return their real paths.

   *t* can be a single string or a list of strings. A string should
   be one of

   1. a relative or absolute path,
   2. a file in one of the directories listed in :data:`bornprofiler.config.path`,
   3. a filename in the package template directory (defined in the template dictionary
      :data:`bornprofiler.config.templates`) or
   4. a key into :data:`~bornprofiler.config.templates`.

   The first match (in this order) is returned for each input argument.

   :Arguments: *t* : template file or key (string or list of strings)
   :Returns:   list of os.path.realpath(*t*)
   :Raises:    :exc:`ValueError` if no file can be located.

   """
    return [_get_template(s) for s in utilities.asiterable(t)]
示例#5
0
def get_templates(t):
    """Find template file(s) *t* and return their real paths.

    *t* can be a single string or a list of strings. A string should
    be one of

    1. a relative or absolute path,
    2. a file in one of the directories listed in :data:`gromacs.config.path`,
    3. a filename in the package template directory (defined in the template dictionary
       :data:`gromacs.config.templates`) or
    4. a key into :data:`~gromacs.config.templates`.

    The first match (in this order) is returned for each input argument.

    :Arguments: *t* : template file or key (string or list of strings)
    :Returns:   list of os.path.realpath(*t*)
    :Raises:    :exc:`ValueError` if no file can be located.

    """
    return [_get_template(s) for s in utilities.asiterable(t)]