def __init__(self,<EOL>G,<EOL>copy_db_path,<EOL>buffer_distance_km=None,<EOL>buffer_lat=None,<EOL>buffer_lon=None,<EOL>update_metadata=True,<EOL>start_date=None,<EOL>end_date=None,<EOL>agency_ids_to_preserve=None,<EOL>agency_distance=None):
if start_date and end_date:<EOL><INDENT>if isinstance(start_date, (datetime.datetime, datetime.date)):<EOL><INDENT>self.start_date = start_date.strftime("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.start_date = start_date<EOL><DEDENT>if isinstance(end_date, (datetime.datetime, datetime.date)):<EOL><INDENT>end_date_dt = end_date<EOL>self.end_date = end_date.strftime("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.end_date = end_date<EOL>end_date_dt = datetime.datetime.strptime(self.end_date, "<STR_LIT>")<EOL><DEDENT>end_date_to_include = end_date_dt - datetime.timedelta(days=<NUM_LIT:1>)<EOL>self.end_date_to_include_str = end_date_to_include.strftime("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>self.start_date = None<EOL>self.end_date = None<EOL><DEDENT>self.copy_db_conn = None<EOL>self.copy_db_path = copy_db_path<EOL>self.agency_ids_to_preserve = agency_ids_to_preserve<EOL>self.gtfs = G<EOL>self.buffer_lat = buffer_lat<EOL>self.buffer_lon = buffer_lon<EOL>self.buffer_distance_km = buffer_distance_km<EOL>self.update_metadata = update_metadata<EOL>if agency_distance is not None:<EOL><INDENT>raise NotImplementedError<EOL><DEDENT>self.this_db_path = self.gtfs.get_main_database_path()<EOL>assert os.path.exists(self.this_db_path), "<STR_LIT>"<EOL>assert os.path.exists(os.path.dirname(os.path.abspath(copy_db_path))),"<STR_LIT>"<EOL>assert not os.path.exists(copy_db_path), "<STR_LIT>" % copy_db_path<EOL>
Copy a database, and then based on various filters.
Only method `create_filtered_copy` is provided as we do not want to take the risk of
losing the data stored in the original database.

G: gtfspy.gtfs.GTFS
    the original database
copy_db_path : str
    path to another database database
update_metadata : boolean, optional
    whether to update metadata of the feed, defaulting to true
    (this option is mainly available for testing purposes)
start_date : str, or datetime.datetime
    filter out all data taking place before end_date (the start_time_ut of the end date)
    Date format "YYYY-MM-DD"
    (end_date_ut is not included after filtering)
end_date : str, or datetime.datetime
    Filter out all data taking place after end_date
    The end_date is not included after filtering.
agency_ids_to_preserve : iterable
    List of agency_ids to retain (str) (e.g. 'HSL' for Helsinki)
    Only routes by the listed agencies are then considered
agency_distance : float
    Only evaluated in combination with agency filter.
    Distance (in km) to the other near-by stops that should be included in addition to
    the ones defined by the agencies.
    All vehicle trips going through at least two such stops would then be included in the
    export. Note that this should not be a recursive thing.
    Or should it be? :)
buffer_lat : float
    Latitude of the buffer zone center
buffer_lon : float
    Longitude of the buffer zone center
buffer_distance : float
    Distance from the buffer zone center (in kilometers)

Returns
-------
None