# Path: pathpy/Log.py
# class Log:
#     """ A simple logging class, that allows to select what messages should
#         be recorded in the output, and where these message should be directed.
#     """
# 
#     ## the output stream to which log entries will be written
#     output_stream = sys.stdout
# 
#     ## The minimum severity level of messages to be logged
#     min_severity  = Severity.INFO
# 
# 
#     @staticmethod
#     def setMinSeverity(severity):
#         """ Sets the minimum sveerity level a message
#         needs to have in order to be recorded in the output stream.
#         By default, any message which has a severity of at least
#         Severity.INFO will be written to the output stream. All messages
#         with lower priority will be surpressed.
#         """
#         Log.min_severity = severity
# 
# 
#     @staticmethod
#     def setOutputStream(stream):
#         """ Sets the output stream to which all messages will be
#             written. By default, this is sys.stdout, but it can be
#             changed in order to redirect the log to a logfile.
#         """
#         output_stream = stream
# 
# 
#     @staticmethod
#     def add(msg, severity=Severity.INFO):
#         """ Adds a message with the given severity to the log. This message will be written
#             to the log output stream, which by default is sys.stdout. A newline character
#             will be added to the message by default.
#         """
#         if severity >= Log.min_severity:
#             ts = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
#             Log.output_stream.write(ts + ' [' + str(severity) + ']\t' + msg + '\n')
#             Log.output_stream.flush()
# 
# Path: pathpy/Log.py
# class Severity(enum.IntEnum):
#     """ An enumeration that can be used to indicate
#         the severity of log messages, and which can be
#         used tpo filter messages based on severities.
#     """
# 
#     ## Error messages
#     ERROR = 4
# 
#     ## Warning messages
#     WARNING = 3
# 
#     ## Informational messages (default minimum level)
#     INFO = 2
# 
#     ## Messages regarding timing and performance
#     TIMING = 1
# 
#     ## Debug messages (really verbose)
#     DEBUG = 0


import numpy as _np
import sys as _sys
import collections as _co
import bisect as _bs
import datetime as _dt
import time as _t
import pathpy.Paths
        import os as _os
from pathpy.Log import Log
from pathpy.Log import Severity
                        if timestamp.isdigit():
                            t = int(timestamp)
                        else:   # if it is a string, we use the timestamp format to convert it to a UNIX timestamp                                
                            x = _dt.datetime.strptime(timestamp, timestampformat)
                            t = int(_t.mktime(x.timetuple()))
                    else:
                        t = n                
                    if t>=0:
                        tedge = (fields[source_ix], fields[target_ix], t)
                        tedges.append(tedge)
                    else:
                        Log.add('Ignoring negative timestamp in line ' + str(n+1) + ': "' + line.strip() + '"', Severity.WARNING)
                except (IndexError, ValueError):
                    Log.add('Ignoring malformed data in line ' + str(n+1) + ': "' +  line.strip() + '"', Severity.WARNING)
                line = f.readline()
                n += 1
        # end of with open()

        return TemporalNetwork(tedges = tedges)



    def filterEdges(self, edge_filter):
        """Filter time-stamped edges according to a given filter expression. 

        @param edge_filter: an arbitrary filter function of the form filter_func(v, w, time) that 
            returns True for time-stamped edges that shall pass the filter, and False for all edges that 
            shall be filtered out.
        """


# Path: pathpy/Log.py
# class Log:
#     """ A simple logging class, that allows to select what messages should
#         be recorded in the output, and where these message should be directed.
#     """
# 
#     ## the output stream to which log entries will be written
#     output_stream = sys.stdout
# 
#     ## The minimum severity level of messages to be logged
#     min_severity  = Severity.INFO
# 
# 
#     @staticmethod
#     def setMinSeverity(severity):
#         """ Sets the minimum sveerity level a message
#         needs to have in order to be recorded in the output stream.
#         By default, any message which has a severity of at least
#         Severity.INFO will be written to the output stream. All messages
#         with lower priority will be surpressed.
#         """
#         Log.min_severity = severity
# 
# 
#     @staticmethod
#     def setOutputStream(stream):
#         """ Sets the output stream to which all messages will be
#             written. By default, this is sys.stdout, but it can be
#             changed in order to redirect the log to a logfile.
#         """
#         output_stream = stream
# 
# 
#     @staticmethod
#     def add(msg, severity=Severity.INFO):
#         """ Adds a message with the given severity to the log. This message will be written
#             to the log output stream, which by default is sys.stdout. A newline character
#             will be added to the message by default.
#         """
#         if severity >= Log.min_severity:
#             ts = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
#             Log.output_stream.write(ts + ' [' + str(severity) + ']\t' + msg + '\n')
#             Log.output_stream.flush()
# 
# Path: pathpy/Log.py
# class Severity(enum.IntEnum):
#     """ An enumeration that can be used to indicate
#         the severity of log messages, and which can be
#         used tpo filter messages based on severities.
#     """
# 
#     ## Error messages
#     ERROR = 4
# 
#     ## Warning messages
#     WARNING = 3
# 
#     ## Informational messages (default minimum level)
#     INFO = 2
# 
#     ## Messages regarding timing and performance
#     TIMING = 1
# 
#     ## Debug messages (really verbose)
#     DEBUG = 0


# Path: pathpy/TemporalNetwork.py
import numpy as _np
import sys as _sys
import collections as _co
import bisect as _bs
import datetime as _dt
import time as _t
import pathpy.Paths
        import os as _os
from pathpy.Log import Log
from pathpy.Log import Severity

                        if timestamp.isdigit():
                            t = int(timestamp)
                        else:   # if it is a string, we use the timestamp format to convert it to a UNIX timestamp                                
                            x = _dt.datetime.strptime(timestamp, timestampformat)
                            t = int(_t.mktime(x.timetuple()))
                    else:
                        t = n                
                    if t>=0:
                        tedge = (fields[source_ix], fields[target_ix], t)
                        tedges.append(tedge)
                    else:
                        Log.add('Ignoring negative timestamp in line ' + str(n+1) + ': "' + line.strip() + '"', Severity.WARNING)
                except (IndexError, ValueError):
                    Log.add('Ignoring malformed data in line ' + str(n+1) + ': "' +  line.strip() + '"', Severity.WARNING)
                line = f.readline()
                n += 1
        # end of with open()

        return TemporalNetwork(tedges = tedges)



    def filterEdges(self, edge_filter):
        """Filter time-stamped edges according to a given filter expression. 

        @param edge_filter: an arbitrary filter function of the form filter_func(v, w, time) that 
            returns True for time-stamped edges that shall pass the filter, and False for all edges that 
            shall be filtered out.
        """


        Log.add('Starting filtering ...', Severity.INFO)