def Validate_Birthday(self, Given_Birthday, Given_Age):
     output = False
     error = ""
     clean = Cleaner()
     result = clean.Clean_Birthday(Given_Birthday)
     #Checks to see if the birthday was cleaned
     if (result[0] != None):
         if (result[1] == ""):
             date_Details = result[0].split("-")
             str_Day = date_Details[0]
             str_Month = date_Details[1]
             str_Year = date_Details[2]
             try:
                 given_Birth_Date = datetime.date(int(str_Year),
                                                  int(str_Month),
                                                  int(str_Day))
                 today = datetime.datetime.now()
                 should_Be_Age = today.year - given_Birth_Date.year - (
                     (today.month, today.day) <
                     (given_Birth_Date.month, given_Birth_Date.day))
                 if should_Be_Age == Given_Age:
                     output = True
                 else:
                     error = "The age given and birthday do not line up"
             except:
                 error = "Birthday is not a valid date"
         else:
             error = result[1]
     else:
         error = "Birthday wasnt not in a logical format"
     return output, error
Exemple #2
0
 def add_section(self, cleaner_id, name):
     """Add a section (cleaners)"""
     self.cleaner_ids.append(cleaner_id)
     self.cleaners[cleaner_id] = Cleaner.Cleaner()
     self.cleaners[cleaner_id].id = cleaner_id
     self.cleaners[cleaner_id].name = name
     self.cleaners[cleaner_id].description = _('Imported from winapp2.ini')
Exemple #3
0
def main():
    description = "Cleans up old backups to leave more room on the backup server." \
                  "\n\nE.g. python cleaner.py -p /path/to/archive -o 3:4 7:7." \
                  "\n\nThe example provided will keep an archive from every 4th day if it's more than 3 days old" \
                  " and archive every 7 days if it's more than a week old." \
                  "\n\nThe format of backups this script takes is BACKUP_SET-VERSION."
    parser = argparse.ArgumentParser(
        description=description, formatter_class=RawDescriptionHelpFormatter)
    parser.add_argument('-p',
                        '--root-path',
                        type=str,
                        required=True,
                        help='The root path of your backups.')
    parser.add_argument(
        '-o',
        '--options',
        type=str,
        required=True,
        nargs='*',
        help='Your age threshold and desired interval size separated by a colon'
    )
    parser.add_argument('-f',
                        '--force',
                        action='store_true',
                        help='Automatically confirms that you want to delete.')
    args = parser.parse_args()

    calc = Calculator(args.root_path, args.options, args.force)
    calc.calculate()

    cleaner = Cleaner(calc)
    cleaner.clean()
 def Validate_Age(self, Given_Age):
     clean = Cleaner()
     result = clean.Clean_Age(Given_Age)
     error = ""
     output = False
     #Checks to see if the Cleaner could clean the Given_Age
     if (result[0] != None):
         current_Age = result[0]
         #Checks to see if current_Age is within the 0-99 range
         if 0 <= current_Age <= 99:
             output = True
         else:
             error = "Age not between 0 and 99"
     else:
         error = result[1]
     return output, error
Exemple #5
0
    def __init__(self, pathname, xlate_cb=None):
        """Create cleaner from XML in pathname.

        If xlate_cb is set, use it as a callback for each
        translate-able string.
        """

        self.action = None
        self.cleaner = Cleaner.Cleaner()
        self.option_id = None
        self.option_name = None
        self.option_description = None
        self.option_warning = None
        self.xlate_cb = xlate_cb
        if None == self.xlate_cb:
            self.xlate_cb = lambda x, y=None: None  # do nothing

        dom = xml.dom.minidom.parse(pathname)

        self.handle_cleaner(dom.getElementsByTagName('cleaner')[0])
Exemple #6
0
import CaptchaGetter as CG
import CropImages as CI
import Cleaner as CL
import os

img_extension = 'png'
captcha_getter_obj = CG.CaptchaGetter(100, img_extension, '../')
path_to_captcha_imgs = captcha_getter_obj.get_dump_path()
captcha_getter_obj.dump_images()
img_cropper = CI.CropImages(path_to_captcha_imgs, img_extension, '../')
img_cropper.crop_and_save_images()
cropped_images_path = img_cropper.get_cropped_images_path()
img_cleaner = CL.Cleaner(cropped_images_path, img_extension, '../')
img_cleaner.clean_images()


# ================ CREATES LABELLED_DATA FOLDER ================ 
labelled_images_path_root = os.path.abspath('../labelled_data')

if not os.path.isdir(labelled_images_path_root):
    os.mkdir(labelled_images_path_root)

for i in range(10):
    if not os.path.isdir(os.path.join(labelled_images_path_root, str(i))):
        os.mkdir(os.path.join(labelled_images_path_root, str(i)))

# after this, manual labelling is needed. sort the files into their folder under the 'labelled_data' folder
Exemple #7
0
 def __init__(self):
     Daemon.__init__(self, pidfile='/tmp/floucapt.pid', stdout='/tmp/floucapt.log', stderr='/tmp/floucapt.error')
     self.quit    = False
     self.logger  = Logger()
     self.cleaner = Cleaner()
Exemple #8
0
class_setter = {
    'rt': True,
    'hashtag': True,
    'mention': True,
    'polytonic': True,
    'links': True,
    'numbers': True,
    'only_alpha': True,
    'consecutives': True,
    'stopWords': True,
    'lower': True,
    'punctuation': True
}

# Load Cleaner -- TO IMPLEMENT
cleaner = Cleaner(class_setter)

# Load Greek core from spacy
nlp = spacy.load('el_core_news_md')


def init_greek_lexicon(greek_sentiment_terms):
    greek_lexicon = {}

    for term in greek_sentiment_terms:
        term_sentiment = term['sentiment']

        greek_lexicon[term['_id']] = {
            'positive': term_sentiment['PosScore'],
            'negative': term_sentiment['NegScore'],
            'objective': term_sentiment['ObjScore']
Exemple #9
0
        data = {}
        data['ip_address'] = IP_ADDRESS
        data['port'] = PORT
        data['endpoints'] = []
        data['endpoints'].append('/devices')
        data['endpoints'].append('/users')
        data['endpoints'].append('/services')
        data = json.dumps(data)
        return data


if __name__ == "__main__":
    conf = {
        '/': {
            'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
        }
    }

    cherrypy.tree.mount(BrokerInfo(), '/', conf)
    cherrypy.tree.mount(DeviceManager.DeviceManager(), '/devices', conf)
    cherrypy.tree.mount(ServiceManager.ServiceManager(), '/services', conf)
    cherrypy.tree.mount(UserManager.UserManager(), '/users', conf)

    cherrypy.config.update({
        'server.socket_host': IP_ADDRESS,
        'server.socket_port': PORT
    })

    Cleaner.Cleaner()
    cherrypy.engine.start()
    cherrypy.engine.block()
Exemple #10
0
		global IP_ADDRESS, PORT
		data = {}
		data['ip_address'] = IP_ADDRESS
		data['port'] = PORT
		data['endpoints'] = []
		data['endpoints'].append('/devices')
		data['endpoints'].append('/users')
		data['endpoints'].append('/services')
		data = json.dumps(data)
		return data

if __name__ == "__main__":
	conf = {
		'/' : {
			'request.dispatch' : cherrypy.dispatch.MethodDispatcher(),
		}
	}
	
	cherrypy.tree.mount(BrokerInfo(), '/', conf)
	cherrypy.tree.mount(DeviceManager.DeviceManager(), '/devices', conf)
	cherrypy.tree.mount(ServiceManager.ServiceManager(), '/services', conf)
	cherrypy.tree.mount(UserManager.UserManager(), '/users', conf)

	cherrypy.config.update({
		'server.socket_host' : IP_ADDRESS,
		'server.socket_port' : PORT
		})

	Cleaner.Cleaner(0, 'cleaner_thread', 0).start()
	cherrypy.engine.start()
	cherrypy.engine.block()