Esempio n. 1
0
def _list_file_stack(fname, ind, digit=None):
    """
    Return a stack of file names in a folder as a list.

    Parameters
    ----------
    fname : str
        String defining the path of file or file name.
    ind : list of int
        Indices of the files to read.
    digit : int
        Deprecated input for the number of digits in all indexes
        of the stacked files.
    """

    if digit is not None:
        warnings.warn(("The 'digit' argument is deprecated and no longer used."
                      "  It may be removed completely in a later version."),
                      FutureWarning)

    body = writer.get_body(fname)
    body, digits = writer.remove_trailing_digits(body)

    ext = writer.get_extension(fname)
    list_fname = []
    for m in ind:
        counter_string = str(m).zfill(digits)
        list_fname.append(body + counter_string + ext)
    return list_fname
Esempio n. 2
0
def _list_file_stack(fname, ind, digit=None):
    """
    Return a stack of file names in a folder as a list.

    Parameters
    ----------
    fname : str
        String defining the path of file or file name.
    ind : list of int
        Indices of the files to read.
    digit : int
        Deprecated input for the number of digits in all indexes
        of the stacked files.
    """

    if digit is not None:
        warnings.warn(("The 'digit' argument is deprecated and no longer used."
                      "  It may be removed completely in a later version."),
                      FutureWarning)

    body = writer.get_body(fname)
    body, digits = writer.remove_trailing_digits(body)

    ext = writer.get_extension(fname)
    list_fname = []
    for m in ind:
        counter_string = str(m).zfill(digits)
        list_fname.append(body + counter_string + ext)
    return list_fname
Esempio n. 3
0
 def test_remove_trailing_digits_handles_empty_string(self):
     text, number_of_digits = writer.remove_trailing_digits("")
     assert_equal(text, "")
     assert_equal(number_of_digits, 0)
Esempio n. 4
0
 def test_remove_trailing_digits_handles_not_having_digits(self):
     text, number_of_digits = writer.remove_trailing_digits("someText")
     assert_equal(text, "someText")
Esempio n. 5
0
 def test_remove_trailing_digits_does_not_remove_digits_in_the_middle(self):
     text, number_of_digits = writer.remove_trailing_digits(
         "8s7o6m5e4T3e2x1t00.0000")
     assert_equal(text, "8s7o6m5e4T3e2x1t00.")
Esempio n. 6
0
 def test_remove_trailing_digits_removes_digits(self):
     text, number_of_digits = writer.remove_trailing_digits(
         "someText1234567890")
     assert_equal(text, "someText")
Esempio n. 7
0
 def test_remove_trailing_digits_removes_correct_number_of_zeroes(self):
     text, number_of_digits = writer.remove_trailing_digits("someText0000")
     assert_equal(number_of_digits, 4)