예제 #1
0
    def write(self, dest=None, format=None, properties=None, prefix=None,
              progress=False, progress_width=80, update_interval=None,
              show_value=True, **kwargs):
        """
        Write all frames to `dest`. If `format` is not
        given it is inferred from the file extension of `dest` (see
        :ref:`fileformats`). If `properties` is present, it should be a list
        of property names to include in the output file, e.g. `['species', 'pos']`.
      
        `progress`, `progress_width`, `update_interval` and `show_value`
        are used to control a textual progress bar. The extra arguments
        in `*args` and `**kwargs` are passed along to the underlying
        writer routine constructed for writing to `dest`.

        See :ref:`fileformats` for a list of supported file formats.
        """
        opened = False
        if dest is None:
            dest = self.source
        filename, dest, format = infer_format(dest, format, AtomsWriters)

        if progress:
            from progbar import ProgressBar
            pb = ProgressBar(0,len(self),progress_width,showValue=show_value)
            update_interval = update_interval or max(1, len(self)/progress_width)

        if format in AtomsWriters:
            dest = AtomsWriters[format](dest, **kwargs)

        if not hasattr(dest, 'write'):
            raise ValueError("Don't know how to write to destination \"%s\" in format \"%s\"" % (dest, format))

        res = []
        for i, a in enumerate(self):
            write_kwargs = {}
            if properties is not None: write_kwargs['properties'] = properties
            if prefix is not None: write_kwargs['prefix'] = prefix
            try:
                res.append(dest.write(a, **write_kwargs))
            except TypeError:
                raise ValueError('destination does not support specifying arguments %r' % write_kwargs)

            if progress and i % update_interval == 0: pb(i)

        if opened:
            dest.close()

        # Special case for writing to a string
        if format == 'string':
            return ''.join(res)
        else:
            if res is not None and not all(el is None for el in res):
                return res
                xlPlotter.Create_Sheet(year)
                # Populate Dates
                xlPlotter.Fill_Dates(yrstart, year)
                # Create the summary tables in Excel
                xlTables.Create_Summary_Table()
            # Extra Graph
            xlPlotter.Create_Sheet(selected_date_sheet)
            xlPlotter.Fill_Dates(
                datetime.datetime(xlPlotter._get_fiscal_year(Last_Pub_Date), 4,
                                  1), selected_date_sheet)

        # Update the ComCom comparison table in excel
        xlTables.Populate_Reliability_Stats()

        # Create a new progress bar
        pb = ProgressBar(len(p.StartDates) + 1, "SAIDI/SAIFI graph(s)")
        pb_thread = threading.Thread(target=update_prog_bar, args=(pb, ))
        pb_thread.start()

        # Fill the series columns, create the graphs
        for yrstart in p.StartDates:
            year = str(yrstart.year)
            xlPlotter.Populate_Fixed_Stats(
                year)  # Com Com table values scaled linearly
            xlPlotter.Populate_Daily_Stats(
                datetime.datetime(yrstart.year + 1, 3, 31),
                year)  # Daily real world SAIDI/SAIDI
            #xlTables.Summary_Table(year)
            xlPlotter.Create_Graphs(datetime.datetime(yrstart.year + 1, 3, 31),
                                    year)
            pb.update_paced()
예제 #3
0
import time
from progbar import ProgressBar

progbar_length = 10  # Length of ProgressBar
num_progbar = 6  # Number of ProgressBars

# List containing the ProgressBar objects of different supported colors
bars = [
    ProgressBar(progbar_length),
    ProgressBar(progbar_length, "purple"),
    ProgressBar(progbar_length, "green"),
    ProgressBar(progbar_length, "red"),
    ProgressBar(progbar_length, "yellow"),
    ProgressBar(progbar_length, "cyan")
]

# This is a ProgressBar with an unsupported color "blue" to demonstrate what'll happen
error_bar = ProgressBar(progbar_length, "blue")

for i in range(0, num_progbar):
    print("ProgressBar {}".format(i + 1))
    for _ in range(0, progbar_length + 1):
        print("\r{}".format(bars[i].bar), end="")
        bars[i].update()
        time.sleep(0.25)
    print()

print("ErrorBar")
for _ in range(0, progbar_length + 1):
    print("\r{}".format(error_bar.bar), end="")
    error_bar.update()