コード例 #1
0
ファイル: test_db.py プロジェクト: Rotaro/JobSearch
 def setUp(self):
     self.filename = ":memory:"
     self.db = db_controls.JobAdDB(self.filename)
     self.db._connect_db()
     self.db_columns = [("site", "varchar(255)", 0), 
                      ("searchterm", "varchar(255)", 0), 
                      ("id", "varchar(255)", 1), 
                      ("title", "varchar(255)", 0),
                      ("url", "varchar(1000)", 0),
                      ("description", "varchar(1000)", 0),
                      ("date", "date", 0),
                      ("language", "varchar(100)", 0),
                      ("relevant", "integer", 0),
                      ("recommendation", "integer", 0)]
     self.job_ads = [{"site" : "best job ads site", "searchterm" : "greatest jobs",
         "id": "xyz412412se", "title" : "Great Job", "url" :"http://www.great.zyx",
         "description":"the absolutely best job"}, 
         {"site" : "worst job ads site", "searchterm" : "worst jobs",
         "id": "dsfewf32", "title" : "Bad Job", "url" :"http://www.poor.zyx",
         "description":"the absolutely worst job"}]
     self.job_ads = [JobAd.create(ad) for ad in self.job_ads]
     self.job_ads_stored = [{"site" : "best job ads site", "searchterm" : "greatest jobs",
         "id": "xyz412412se", "title" : "Great Job", "url" :"http://www.great.zyx",
         "description":"the absolutely best job", "date" : datetime.date.today(), 
         "language" : None, "relevant": None, "recommendation" : None},
         {"site" : "worst job ads site", "searchterm" : "worst jobs",
         "id": "dsfewf32", "title" : "Bad Job", "url" :"http://www.poor.zyx",
         "description":"the absolutely worst job", "date" : datetime.date.today(), 
         "language" : None, "relevant": None, "recommendation" : None}]
     self.job_ads_stored = [JobAd.create(ad) for ad in self.job_ads_stored]
     self.job_ads_garbage = [{"site" : "best job ads site", "searchterm" : "greatest jobs",
         "id": "xyz412412se", "title" : "Great Job", "url" :"http://www.great.zyx",
         "description":"the absolutely best job", "falsekey" : "garbage"}, 
         {"site" : "worst job ads site", "searchterm" : "worst jobs",
         "id": "dsfewf32", "title" : "Bad Job", "url" :"http://www.poor.zyx",
         "description":"the absolutely worst job", "falsekey" : "garbage"}]
     self.job_ads_garbage = [JobAd.create(ad) for ad in self.job_ads_garbage]
     self.job_ads_classified = [{"site" : "best job ads site", "searchterm" : "greatest jobs",
         "id": "xyz412412se", "title" : "Great Job", "url" :"http://www.great.zyx",
         "description":"the absolutely best job", "date" : datetime.date.today(), 
         "language" : "English", "relevant": 1, "recommendation" : None}, 
         {"site" : "worst job ads site", "searchterm" : "worst jobs",
         "id": "dsfewf32", "title" : "Bad Job", "url" :"http://www.poor.zyx",
         "description":"the absolutely worst job", "date" : datetime.date.today(), 
         "language" : "English", "relevant": 0, "recommendation" : None}]
     self.job_ads_classified = [JobAd.create(ad) for ad in self.job_ads_classified]
     self.job_ads_classified_less = [{"site" : "best job ads site", 
         "searchterm" : "greatest jobs", "title" : "Great Job", 
         "description":"the absolutely best job", "language" : "English", "relevant": 1}, 
         {"site" : "worst job ads site", "searchterm" : "worst jobs",
         "title" : "Bad Job", "description":"the absolutely worst job", 
         "language" : "English", "relevant": 0}]
     self.job_ads_classified_less = [JobAd.create(ad) for ad in self.job_ads_classified_less]
コード例 #2
0
ファイル: jobadcollector.py プロジェクト: Rotaro/JobSearch
    def classify_ads_GUI(self, date_start, date_end):
        """Starts GUI for classifying database entries between given dates.
        
        All job ads between argument dates are included for classification. 

        Arguments
        ----------
        date_start : :class:`datetime`
            Earliest date of job ads. If None, all job ads since the start of
            the database are included.
        date_end : :class:`datetime`
            Latest date of job ads. If None, all job ads after date_start are 
            included. If both date_start and date_end are None, all job ads in 
            the database are included.
        """
        datab = db_controls.JobAdDB(self._db_name)

        gui = db_gui.JobAdGUI(datab.get_ads(date_start, date_end))
        gui.mainloop()
        new_data = gui.ad_storage  # dictionary with ids as keys
        new_data_dict = [JobAd.create(dict(zip(gui._db_data_columns, new_data[id]))) for id in new_data]

        datab.update_ads(new_data_dict)
コード例 #3
0
    def classify_ads_GUI(self, date_start, date_end):
        """Starts GUI for classifying database entries between given dates.
        
        All job ads between argument dates are included for classification. 

        Arguments
        ----------
        date_start : :class:`datetime`
            Earliest date of job ads. If None, all job ads since the start of
            the database are included.
        date_end : :class:`datetime`
            Latest date of job ads. If None, all job ads after date_start are 
            included. If both date_start and date_end are None, all job ads in 
            the database are included.
        """
        datab = db_controls.JobAdDB(self._db_name)

        gui = db_gui.JobAdGUI(datab.get_ads(date_start, date_end))
        gui.mainloop()
        new_data = gui.ad_storage  # dictionary with ids as keys
        new_data_dict = [JobAd.create(dict(zip(gui._db_data_columns, new_data[id])))
                         for id in new_data]
        
        datab.update_ads(new_data_dict)
コード例 #4
0
 def setUp(self):
     self.filename = ":memory:"
     self.db = db_controls.JobAdDB(self.filename)
     self.db._connect_db()
     self.db_columns = [("site", "varchar(255)", 0),
                        ("searchterm", "varchar(255)", 0),
                        ("id", "varchar(255)", 1),
                        ("title", "varchar(255)", 0),
                        ("url", "varchar(1000)", 0),
                        ("description", "varchar(1000)", 0),
                        ("date", "date", 0),
                        ("language", "varchar(100)", 0),
                        ("relevant", "integer", 0),
                        ("recommendation", "integer", 0)]
     self.job_ads = [{
         "site": "best job ads site",
         "searchterm": "greatest jobs",
         "id": "xyz412412se",
         "title": "Great Job",
         "url": "http://www.great.zyx",
         "description": "the absolutely best job"
     }, {
         "site": "worst job ads site",
         "searchterm": "worst jobs",
         "id": "dsfewf32",
         "title": "Bad Job",
         "url": "http://www.poor.zyx",
         "description": "the absolutely worst job"
     }]
     self.job_ads = [JobAd.create(ad) for ad in self.job_ads]
     self.job_ads_stored = [{
         "site": "best job ads site",
         "searchterm": "greatest jobs",
         "id": "xyz412412se",
         "title": "Great Job",
         "url": "http://www.great.zyx",
         "description": "the absolutely best job",
         "date": datetime.date.today(),
         "language": None,
         "relevant": None,
         "recommendation": None
     }, {
         "site": "worst job ads site",
         "searchterm": "worst jobs",
         "id": "dsfewf32",
         "title": "Bad Job",
         "url": "http://www.poor.zyx",
         "description": "the absolutely worst job",
         "date": datetime.date.today(),
         "language": None,
         "relevant": None,
         "recommendation": None
     }]
     self.job_ads_stored = [JobAd.create(ad) for ad in self.job_ads_stored]
     self.job_ads_garbage = [{
         "site": "best job ads site",
         "searchterm": "greatest jobs",
         "id": "xyz412412se",
         "title": "Great Job",
         "url": "http://www.great.zyx",
         "description": "the absolutely best job",
         "falsekey": "garbage"
     }, {
         "site": "worst job ads site",
         "searchterm": "worst jobs",
         "id": "dsfewf32",
         "title": "Bad Job",
         "url": "http://www.poor.zyx",
         "description": "the absolutely worst job",
         "falsekey": "garbage"
     }]
     self.job_ads_garbage = [
         JobAd.create(ad) for ad in self.job_ads_garbage
     ]
     self.job_ads_classified = [{
         "site": "best job ads site",
         "searchterm": "greatest jobs",
         "id": "xyz412412se",
         "title": "Great Job",
         "url": "http://www.great.zyx",
         "description": "the absolutely best job",
         "date": datetime.date.today(),
         "language": "English",
         "relevant": 1,
         "recommendation": None
     }, {
         "site": "worst job ads site",
         "searchterm": "worst jobs",
         "id": "dsfewf32",
         "title": "Bad Job",
         "url": "http://www.poor.zyx",
         "description": "the absolutely worst job",
         "date": datetime.date.today(),
         "language": "English",
         "relevant": 0,
         "recommendation": None
     }]
     self.job_ads_classified = [
         JobAd.create(ad) for ad in self.job_ads_classified
     ]
     self.job_ads_classified_less = [{
         "site": "best job ads site",
         "searchterm": "greatest jobs",
         "title": "Great Job",
         "description": "the absolutely best job",
         "language": "English",
         "relevant": 1
     }, {
         "site": "worst job ads site",
         "searchterm": "worst jobs",
         "title": "Bad Job",
         "description": "the absolutely worst job",
         "language": "English",
         "relevant": 0
     }]
     self.job_ads_classified_less = [
         JobAd.create(ad) for ad in self.job_ads_classified_less
     ]