# Path: Timeline.py
# class Timeline(object):
#     CLASS_SUCCESS = "success"
#     CLASS_WARN = "warning"
#     CLASS_INFO = "info"
#     CLASS_PRIMARY = "primary"
#     
#     _DATES_KEYFORM = "{day}{month}{year}"
#     def __init__(self):
#         self.items = []
#         self.timeline_dates = {}
#         return
#     
#     def _convertunix(self, unix):
#         if type(unix) in [str,unicode]:
#             if unix.isdigit(): unix = int(unix)
#             else: return None
#         return unix
#     
#     def _get_month_from_unix(self,unix):
#         unix = self._convertunix(unix)
#         try:
#             return datetime.fromtimestamp(unix).strftime('%b')
#         except:
#             return None
#     
#     def _get_day_from_unix(self, unix):
#         unix = self._convertunix(unix)
#         try:
#             return datetime.fromtimestamp(unix).strftime('%d')
#         except:
#             return None
#     
#     def add_item(self, item):
#         item.date = self._convertunix(item.date)
#         if item.date == None: return
#         dt = datetime.fromtimestamp(item.date)
#         try:
#             item_day = dt.strftime('%d')
#             item_month = dt.strftime('%b')
#             item_year = dt.strftime('%Y')
#         except:
#             return
#         
#         key = self._DATES_KEYFORM.format(day=item_day,month=item_month,
#                                          year=item_year)
#         if key in self.timeline_dates:
#             self.timeline_dates[key].add_item(item)
#         else:
#             day_date = datetime.fromtimestamp(item.date).date()
#             day_tsmp = time.mktime(day_date.timetuple())
#             timeline_date = TimelineDate( day_tsmp, item_day, item_month, 
#                                           item_year, [item] )
#             bisect.insort(self.items, timeline_date)
#             self.timeline_dates[key] = timeline_date
#         return
#     
#     def _get_beginning_ofmonth(self):
#         today = date.today()
#         fdmonth = date(today.year, today.month, 1)
#         return int(time.mktime(fdmonth.timetuple()))
#     
#     def get_items(self, start=None, end=None, force_month=False ):
#         if force_month == False:
#             if start == None and end == None:
#                 return self.items
#         
#         start = self._convertunix(start)
#         end = self._convertunix(end)
#         
#         if start == None:
#             start = self._get_beginning_ofmonth()
#         if end == None:
#             end = int(time.time())
#         print "Start: {}({}) end: {}({})".format(type(start),start,type(end),end)        
#         res = [ i for i in self.items if i.day_timestamp >= start and 
#                 i.day_timestamp <= end ]
#         print "Got: {}".format(len(res))
#         return res


import os, string
import Includes
        import cPickle, time, marshal
        import cPickle,marshal
from Timeline import Timeline
        if int_name in self.sections:
            return self.sections[int_name]
        if create_new:
            newsection = MiscSection( section_label )
            self.add_section( newsection )
            return newsection
        return None
    
class ExtractStore(object):
    
    store = []
    misc_catalogs = {}
    timeline = None
    def __init__(self):
        self.store = []
        self.misc_catalogs = {}
        return
    
    """
    Add the application's package name in order to generate the appropriate
    structure for this application
    Params:
        - package_name: The application's package name (string)
    """
    def create_application(self, package_name, canonical_name=None):
        app = Application(package_name, canonical_name)
        self.store.append(app)
        return app
    
    def create_timeline(self):

# Path: Timeline.py
# class Timeline(object):
#     CLASS_SUCCESS = "success"
#     CLASS_WARN = "warning"
#     CLASS_INFO = "info"
#     CLASS_PRIMARY = "primary"
#     
#     _DATES_KEYFORM = "{day}{month}{year}"
#     def __init__(self):
#         self.items = []
#         self.timeline_dates = {}
#         return
#     
#     def _convertunix(self, unix):
#         if type(unix) in [str,unicode]:
#             if unix.isdigit(): unix = int(unix)
#             else: return None
#         return unix
#     
#     def _get_month_from_unix(self,unix):
#         unix = self._convertunix(unix)
#         try:
#             return datetime.fromtimestamp(unix).strftime('%b')
#         except:
#             return None
#     
#     def _get_day_from_unix(self, unix):
#         unix = self._convertunix(unix)
#         try:
#             return datetime.fromtimestamp(unix).strftime('%d')
#         except:
#             return None
#     
#     def add_item(self, item):
#         item.date = self._convertunix(item.date)
#         if item.date == None: return
#         dt = datetime.fromtimestamp(item.date)
#         try:
#             item_day = dt.strftime('%d')
#             item_month = dt.strftime('%b')
#             item_year = dt.strftime('%Y')
#         except:
#             return
#         
#         key = self._DATES_KEYFORM.format(day=item_day,month=item_month,
#                                          year=item_year)
#         if key in self.timeline_dates:
#             self.timeline_dates[key].add_item(item)
#         else:
#             day_date = datetime.fromtimestamp(item.date).date()
#             day_tsmp = time.mktime(day_date.timetuple())
#             timeline_date = TimelineDate( day_tsmp, item_day, item_month, 
#                                           item_year, [item] )
#             bisect.insort(self.items, timeline_date)
#             self.timeline_dates[key] = timeline_date
#         return
#     
#     def _get_beginning_ofmonth(self):
#         today = date.today()
#         fdmonth = date(today.year, today.month, 1)
#         return int(time.mktime(fdmonth.timetuple()))
#     
#     def get_items(self, start=None, end=None, force_month=False ):
#         if force_month == False:
#             if start == None and end == None:
#                 return self.items
#         
#         start = self._convertunix(start)
#         end = self._convertunix(end)
#         
#         if start == None:
#             start = self._get_beginning_ofmonth()
#         if end == None:
#             end = int(time.time())
#         print "Start: {}({}) end: {}({})".format(type(start),start,type(end),end)        
#         res = [ i for i in self.items if i.day_timestamp >= start and 
#                 i.day_timestamp <= end ]
#         print "Got: {}".format(len(res))
#         return res


# Path: ExtractStore.py
import os, string
import Includes
        import cPickle, time, marshal
        import cPickle,marshal
from Timeline import Timeline

        if int_name in self.sections:
            return self.sections[int_name]
        if create_new:
            newsection = MiscSection( section_label )
            self.add_section( newsection )
            return newsection
        return None
    
class ExtractStore(object):
    
    store = []
    misc_catalogs = {}
    timeline = None
    def __init__(self):
        self.store = []
        self.misc_catalogs = {}
        return
    
    """
    Add the application's package name in order to generate the appropriate
    structure for this application
    Params:
        - package_name: The application's package name (string)
    """
    def create_application(self, package_name, canonical_name=None):
        app = Application(package_name, canonical_name)
        self.store.append(app)
        return app
    
    def create_timeline(self):

        self.timeline = Timeline()