# Path: utils/settings/_settings.py
# _DEFAULT=object() # unique object to compare identity with
# class EmptyMapping(Mapping):
# class ImmutableMapping(Mapping):
# class EmptySection(EmptyMapping):
# class SettingsSection(ImmutableMapping):
# class Settings(object):
#   def __init__(self,default=None):
#   def __getitem__(self,key):
#   def __len__(self):
#   def __iter__(self):
#   def __contains__(self,key):
#   def get(self, key, default=_DEFAULT):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self,_dict,default=None):
#   def __getitem__(self,key):
#   def __len__(self):
#   def __iter__(self):
#   def __contains__(self,key):
#   def get(self, key, default=_DEFAULT):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self):
#   def sections(self):
#   def getsection(self,key,**kwargs):
#   def __eq__(self,other):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self,sections,values):
#   def sections(self):
#   def getsection(self,key,**kwargs):
#   def __getattr__(self,name):
#   def __eq__(self,other):
#   def __str__(self):
#   def __repr__(self):
# def _mergesettings(parent,sectiondict,section,value):
# def _loadsettings(filename,parent=None):
# def __print(section,indent=""):
#   def __new__(cls):
#   def system(self):
#   def user(self):
#   def get(self,user):


import subprocess as sp
import os
import datetime
import calendar
from utils.settings import settings
         'lifetime':(maximumage,ageunit)
        },
        ...
    },
    'schedule':[('profilename',timebetweenupdates,timeunit), ...]
}

Each profile describes a type of backup including what is included in the backup and how long it is kept for.
Either the 'base' entry or the 'targets' and 'exclusions' entries must be specified. If 'base' is specified
then this profiles inherits settings from the named profile. If the profile has a base and has some targets
specified then if 'replace_targets' is True the base profiles targets are replaced, otherwise the are combined.
The equivelent applies with exclusions and replace_exclusions. It is not valid to have a cycle in the 'base'
relations and if this occurs the result is unspecified.
NOTE: Profile names can only contain alphanumerics and _.

If a profile has a lifetime then any backups older than this amount of time are automatically deleted after
the update.

The schedule is an ordere list of entries. Each entry is tried in turn and if the latest backup of the
specified profile is older than the specified amount of time then that profile will be used. The last entry
should have a timeperiod of 0 so at least one entry will match.

It is also possible to call backup and manually specify a backup profile to use.

The timespecs are an amount and a unit where the unit is one of the strings 'year','month','week','day'.
Months and years are calender months and years respectively and month rounds the day down if out of
range for the resulting month.
"""

BACKUPDIR=settings.user.getsection('backup').get('directory',"backup")

# Path: utils/settings/_settings.py
# _DEFAULT=object() # unique object to compare identity with
# class EmptyMapping(Mapping):
# class ImmutableMapping(Mapping):
# class EmptySection(EmptyMapping):
# class SettingsSection(ImmutableMapping):
# class Settings(object):
#   def __init__(self,default=None):
#   def __getitem__(self,key):
#   def __len__(self):
#   def __iter__(self):
#   def __contains__(self,key):
#   def get(self, key, default=_DEFAULT):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self,_dict,default=None):
#   def __getitem__(self,key):
#   def __len__(self):
#   def __iter__(self):
#   def __contains__(self,key):
#   def get(self, key, default=_DEFAULT):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self):
#   def sections(self):
#   def getsection(self,key,**kwargs):
#   def __eq__(self,other):
#   def __str__(self):
#   def __repr__(self):
#   def __init__(self,sections,values):
#   def sections(self):
#   def getsection(self,key,**kwargs):
#   def __getattr__(self,name):
#   def __eq__(self,other):
#   def __str__(self):
#   def __repr__(self):
# def _mergesettings(parent,sectiondict,section,value):
# def _loadsettings(filename,parent=None):
# def __print(section,indent=""):
#   def __new__(cls):
#   def system(self):
#   def user(self):
#   def get(self,user):


# Path: utils/backups/backups.py
import subprocess as sp
import os
import datetime
import calendar
from utils.settings import settings

         'lifetime':(maximumage,ageunit)
        },
        ...
    },
    'schedule':[('profilename',timebetweenupdates,timeunit), ...]
}

Each profile describes a type of backup including what is included in the backup and how long it is kept for.
Either the 'base' entry or the 'targets' and 'exclusions' entries must be specified. If 'base' is specified
then this profiles inherits settings from the named profile. If the profile has a base and has some targets
specified then if 'replace_targets' is True the base profiles targets are replaced, otherwise the are combined.
The equivelent applies with exclusions and replace_exclusions. It is not valid to have a cycle in the 'base'
relations and if this occurs the result is unspecified.
NOTE: Profile names can only contain alphanumerics and _.

If a profile has a lifetime then any backups older than this amount of time are automatically deleted after
the update.

The schedule is an ordere list of entries. Each entry is tried in turn and if the latest backup of the
specified profile is older than the specified amount of time then that profile will be used. The last entry
should have a timeperiod of 0 so at least one entry will match.

It is also possible to call backup and manually specify a backup profile to use.

The timespecs are an amount and a unit where the unit is one of the strings 'year','month','week','day'.
Months and years are calender months and years respectively and month rounds the day down if out of
range for the resulting month.
"""

BACKUPDIR=settings.user.getsection('backup').get('directory',"backup")

TIMESTAMPFORMAT=settings.user.getsection('backup').get('timestamptformat',"%Y.%m.%d %H:%M:%S.%f")